How to vlookup on 2 columns and return total value of another? - excel

I've got a table in Excel which is structure like so:
Month Date Time ID Name Currency Value
Jan 07/01/14 5 1234567 Ted GBP 500
Jan 10/01/14 12 1234567 Ted GBP 723
Feb 23/02/14 6 9877654 John GBP 300
Feb 10/02/14 10 1234567 Ted GBP 333
What I need to do is write a formula which basically returns be the total of Value where ID and Month are equal to whatever the lookup values are. For example, using the above I would say:
Find the total of Value where Month equals Jan and ID equals 1234567.
The answer in this case would be 1223.
Ive just tried
=SUMIFS(INPUT!H:H,INPUT!D:D='TRANS BY MID'!B2,INPUT!A:A='TRANS BY MID'!C1)
INPUT!H:H is my ID column
INPUT!D:D='TRANS BY MID'!B2 is the ID I want to use
INPUT!A:A is the Month column
TRANS BY MID'!C1 is Jan

To provide a working solution I simplified your question into one sheet. The data appears like this:
You can link your other sheet to the values shown in column J.
The formula is now this:
=SUMIFS(G:G,D:D,J1,A:A,J2)
The result is shown in J7:

Related

Excel: Calculation with different beginning dates

I have a long time-series of monthly returns for the S&P500. I would like to calculate the 3-month return, for a subset of dates?
For example, I would like to calculate the 3-month return for the following
A B C
Month Year 3-Month Return
Jan 1929
Dec 1948
July 1981
I have monthly return data like:
A B C
Month Year Monthly Return
Jan 1929 0.102
Feb 1929 0.072
Mar 1929 -0.231
....
....
Dec 2019 0.157
So the first calculation would be something like (1+0.102)(1+0.072)(1-0.231)-1. I can do this manually but have many calculations, unfortunately.
to find the match, you need a unique column, so combine A & B to another column, so that the month+year combination is unique, then use that combination to find the values.
Suppose you have data in this form:
The formula for match index is =match(P3,U$3:U$13,0) and that for your 3 monthly return is =(1+index(V$3:V$13,Q3))*(1+index(V$3:V$13,Q3+1))*(1+index(V$3:V$13,Q3+2))-1
You can put the match index inside the formula in C column to avoid the column, but you'd have to put it 3 times. you can also use different combination for combined date, like the actual date format of mm/yyyy, it'll still work.

How to check if a record exists based on month and persons name (where the name is duplicated)?

I have a data-set with some names and months, sample:
Name Month
Max 2
Sally 5
Max 1
James 11
Richard 9
Sally 9
I then have a table as such:
Month
Name 1 2 3 4 5 6 7 8 9 10 11 12
Max
Sally
James
Richard
How do I create a formula that can enter "Yes", or "No" for each month based on the person's name? For example, Max would have months 2 and 1 displaying "Yes", all other months displaying "No".
I can't think of how to do this...using an INDEX/MATCH function I can pull up the first month for "Max", but it won't register the second time his name shows up (it just matches the order of his name with where his data lies in the array, doesn't consider duplicates).
Is there a way to do this?
Thanks.
Assuming a data setup like this:
In cell E3 and copied over and down is this formula:
=IF(COUNTIFS($A$2:$A$7,$D3,$B$2:$B$7,E$2),"Yes","No")

Excel formula that returns sum based on categorical and date data from 2 columns?

I have a dataset in excel that looks like this:
Supplier Date QTY
A 03/02/2018 10
A 05/01/2018 15
A 08/06/2018 30
B 02/01/2018 20
B 04/01/2018 50
B 08/01/2018 40
B 08/15/2018 50
B 10/01/2018 60
C 03/09/2018 25
C 04/08/2018 25
C 05/20/2018 25
And I want to make a spreadsheet that allows the user to enter start and end dates and the Supplier name and be able to see a total quantity of items received in that time period from that supplier.
I've tried using a combination of VLOOKUP and SUM, but I've only been able to get the first result of the quantity associated with that supplier to return. I understand that this is the nature of VLOOKUP--to only return one value. I'm pretty new to Excel so I just don't really even know which function(s) would be best to use in this scenario.
Example Output:
Enter Supplier: "B"
Enter Start Date: "03/01/2018"
Enter End Date: "09/01/2018"
Items Received: 140
Try:
=SUMPRODUCT((A2:A12=F1)*(B2:B12>=F2)*(B2:B12<=F3)*(C2:C12))
Result:

How to calculate workdays and compensation for given period based on Employee's monthly salary?

I have only three editable fields:
salary = 15,000
start date = 18 Jul 2014
end date = 12 Oct 2014
With these fields, I need to calculate the total salary I need to pay. Payment is on a monthly basis:
(JULY = 15,000 / 31 * 14) +
(AUG = 15,000 / 31 * 31) +
(SEPT = 15,000 / 30 * 30) +
(OCT = 15,000 / 30 * 12).
I can get total days based on both dates (ie 87 days, =DAYS($enddate,$startdate)+1) ) but I need to split the days according to the months.
What formula do I need automatically to get the amount, because each person will have different salary and different dates?
You can use Excel VBA custom Function to solve your problem:
1). First, you should populate Excel Worksheet with data structure reflecting Employees Name, Monthly Salary, StartDate and EndDate, like in the following sample:
Employee M.Salary Start Date EndDate
John $15,000.00 7/18/2014 10/12/2014
Ann $20,000.00 7/19/2014 10/13/2014
Peter $16,000.00 7/20/2014 10/14/2014
Jeff $25,000.00 7/21/2014 10/15/2014
2). The DAYS in date range can be simply found by subtraction (EndDate-StartDate), because the underlying data type in integer
3). For general solution to the problem (Calculate the compensation for any arbitrary period and monthly salary) you will need to create custom VBA formula and use it in a separate column for each Employee. Refer to this article for explanation: Create a custom worksheet function in Excel VBA
4). Pertinent to your particular case with fixed date rage, the simplified solution based on the Excel Worksheet formulas (no VBA) is described below:
Employee MoSalary Start End Days FullMo FirstMo LastMo Total
John $15,000.00 7/18/2014 10/12/2014 87 30000.00 $6,774.19 $6,000.00 $42,774.19
Ann $20,000.00 7/18/2014 10/12/2014 87 40000.00 $9,032.26 $8,000.00 $57,032.26
Peter $16,000.00 7/18/2014 10/12/2014 87 32000.00 $7,225.81 $6,400.00 $45,625.81
Jeff $25,000.00 7/18/2014 10/12/2014 87 50000.00 $11,290.32 $10,000.00 $71,290.32
4a). In column E starting with row 2 add formula for DAYS : =(D2-C2)+1 and extend it for entire range
4b). In column F starting with row 2 add formula for whole months : =2*B2 and extend it for entire range
4c). In column G starting with row 2 add formula for the first month : =14*B2/31 and extend it for entire range
4d). In column H starting with row 2 add formula for last month : =12*B2/30 and extend it for entire range
4e). In column I starting with row 2 add formula for total compensation : =SUM(F2:H2) and extend it for entire range
Hope this will help. Best regards,
I have split this out because I am not entirely sure what you require and you may be able to assemble the pieces in a way that better suits you:
Assuming your data is in A1:A3, put 1/7/14 in C1, 1/8/14 in D1, 1/9/14 in E1 and 1/10/14 in F1.
To count the number of applicable days by month, in C2 enter:
=IF(MONTH($A2)=MONTH(C1),EOMONTH(C1,0)-$A2+1,IF(MONTH($A3)=MONTH(C1),DAY($A3),EOMONTH(C1,0)-EOMONTH(C1,-1)))
To compute the salary for the month by computing the daily rate for the applicable month and multiplying that by the number of days from above, in C3 enter:
=$A1*C2/(DAYS(EOMONTH(C1,0),C1)+1)
Format C2:C3 to suit and copy across to F2:F3.

Excel to find value from one sheet & show to another sheet

I have a sheet1 where column A= employees name & column B=Status (present, absent, etc), I prepare Daily attendance in each sheets, so I have 31 sheets in a month. Now I have a new sheet November. in this sheet column A is employees name and column B, C, D, etc for each days status. show me status of each employes in each days B, C, etc
You would use the VLOOKUP statement to fetch the status from the other sheets.
This is in the format:
vlookup([cell which has the value you want to lookup], [range of cells which contain the table], [column you want to return from that table]). Hopefully this is explained in the example below:
For ease of explanation, imagine your sheets are named Nov1, Nov2... Nov29, Nov30 and NOVEMBER.
Nov1:
A B
1 Employee Name Status
2 Albert Present
3 Brian Absent
4 Catherine Present
5 David Present
6 Edward Present
Nov2:
A B
1 Employee Name Status
2 Albert Absent
3 Brian Absent
4 Catherine Present
5 David Absent
6 Edward Absent
Then, in your sheet NOVEMBER, which is the month summary, use the formulae:
A B C
1 Employee Name Nov 1st Nov 2nd
2 Albert =VLOOKUP($A2,Nov1!$A$2:$B$6,2) =VLOOKUP($A2,Nov2!$A$2:$B$6,2)
3 Brian =VLOOKUP($A3,Nov1!$A$2:$B$6,2) =VLOOKUP($A3,Nov2!$A$2:$B$6,2)
4 Catherine =VLOOKUP($A4,Nov1!$A$2:$B$6,2) =VLOOKUP($A4,Nov2!$A$2:$B$6,2)
5 David =VLOOKUP($A5,Nov1!$A$2:$B$6,2) =VLOOKUP($A5,Nov2!$A$2:$B$6,2)
6 Edward =VLOOKUP($A6,Nov1!$A$2:$B$6,2) =VLOOKUP($A6,Nov2!$A$2:$B$6,2)
Using the $ symbol will mean you can copy down the column and the formulae will update automatically. Ensure that the list of employees in your separate daily sheets are in alphabetical order.
So this should result in something like this:
A B C
1 Employee Name Nov 1st Nov 2nd
2 Albert Present Absent
3 Brian Absent Absent
4 Catherine Present Present
5 David Present Absent
6 Edward Present Absent

Resources