How to get the corresponding values of the latest date in Excel? - excel

I have this values in my excel:
A B C D
StaffId FSales ESales Date
1 100 500 23-Jan-13
1 50 170 25-Jan-13
1 70 230 26-Jan-13
2 100 300 25-Jan-13
2 130 200 27-Jan-13
Outcome wanted:
A B C D
StaffId FSales ESales Date
1 100 500 23-Jan-13 10:00:00AM
1 50 170 25-Jan-13 11:00:00AM
1 70 230 26-Jan-13 11:30:00AM
2 100 300 25-Jan-13 03:00:00PM
2 130 200 27-Jan-13 02:00:00PM
3 100 200 29-Jan-13 01:01:00PM
3 90 209 29-Jan-13 01:00:00PM
A B C D
StaffId FSales ESales Date
1 70 230 26-Jan-13 11:30:00AM
2 130 200 27-Jan-13 02:00:00PM
3 100 200 29-Jan-13 01:01:00PM
Lets say dates are jumbled up and not arranged in any order. How can i get the latest date Fsales and ESales for each staff?
Meaning getting 70 230 for staffid 1 and 130 200 for staffid 2.
Help needed please

Assuming you have the second list with the unique staff ID in Sheet2 and the original list in Sheet1, starting in row 2, enter the following formula:
FSales max in Sheet2!B2: =INDEX(Sheet1!$B:$B,MATCH(MAX(Sheet1!$D:$D*(Sheet1!$A:$A=A2)),(Sheet1!$D:$D*(Sheet1!$A:$A=A2)),0))
ESales max in Sheet2!C2: =INDEX(Sheet1!$C:$C,MATCH(MAX(Sheet1!$D:$D*(Sheet1!$A:$A=A2)),(Sheet1!$D:$D*(Sheet1!$A:$A=A2)),0))
Both formulas are array-formulas, i.e. enter them with Ctrl-Shift-Enter instead of Enter.

Related

Finding a formula to compute partial sums for consecutive rows that satisfy a condition

How do I do this is excel. The example is provided below. If we don't sell any products on a specific day I would like to move those hours to the next date.
If you need to compute partial sums of Hours for all the consecutive rows between rows that satisfy the condition that the value Sold is greater than zero, you could do this with an auxiliary column
A B C D
---------------------------------
1 |Hours Sold Sums Solution
2 | 300 30 300 300
3 | 30 0 300 0
4 | 0 0 300 0
5 | 30 0 300 0
6 | 300 50 660 360
7 | 23 0 660 0
8 | 100 25 783 123
Here Sums is defined by a formula for C2
=IF(B2>0,SUM(A2:$A$2),C1)
You can automatically populate the cells below.
This formula puts in a cell a partial sum of Hours up to the current row if Sold is nonzero, otherwise copies the previous partial sum of hours. We need this to subtract this value on the next step.
When you have the column C filled, it is sufficient to put the following formula in D2 and populate the cells below
=IF(ROW(B2)>2,IF(B2>0,C2-C1,0),C2)
This formula handles correctly both D2 that does not have a preceding row with values and the remaining cells in column D.
In fact you could combine the two formulas together and avoid the need to have an auxiliary column. Put the following formula in C2 and spread it down to the rest of the cells in column C
=IF(ROW(B2)>2,IF(B2>0,SUM(A2:$A$2)-SUM(C1:$C$2),0),A2)
to get
A B C
---------------------------------
1 |Hours Sold Solution
2 | 300 30 300
3 | 30 0 0
4 | 0 0 0
5 | 30 0 0
6 | 300 50 360
7 | 23 0 0
8 | 100 25 123

Change array of SUMIF in case criteria exists in two different columns

A B C D E F
1 Results List A List B
2 Campaign Sales Campaign Sales Campaign Sales
3 Campaign_A 1.510 Campaign_A 500 Campaign_B 50
4 Campaign_B 120 Campaign_A 450 Campaign_B 40
5 Campaign_C 90 Campaign_A 560 Campaign_B 30
6 Campaign_D 1.650 Campaign_B 700 Campaign_C 80
7 Campaign_E 100 Campaign_B 710 Campaign_C 10
8 Campaing_F 70 Campaign_C 200 Campaign_F 70
9 Campaing_D 850
10 Campaing_D 800
11 Campaing_E 100
12 Campaing_F 320
13 Campaing_F 360
14 Campaing_F 290
15
16
The Excel table above consists of:
List A = Column C:D
List B = Column E:F
In each list campaigns can appear mutliple times.
In Column A:B I want to sum up the sales per campaign from the two lists using the SUMIF formula:
=SUMIF(C:C,A3,D:D)
=SUMIF(E:E,A3,F:F)
However, the List B should be prioritized over List A which means in case a campaign exists in List B (Column E) the SUMIF function should be only applied to List B and List A should be totally ignored.
The formula might look something like htis:
IF campaign exists in Column E then SUMIF(E:E,A3,F:F) else SUMIF(C:C,A3,D:D)
How can I achieve the desired results in Column B?
Or,
=IF(COUNTIF(E:E,A3)>0,SUMIF(E:E,A3,F:F),SUMIF(C:C,A3,D:D))
I would try with the following:
if(sumIf(E:E,A3,F:F)>0;sumIf(E:E,A3,F:F);sumIf(C:C,A3,D:D))

Latest Value from the column level to specific code

Can anyone pls help me to get the latest/running value for A & B....
NAME FSales ESales
A 100 500
A 50 170
B 100 300
B 130 200
A 70 230
B 50 450
OUTPUT SHOULD BE
Output FSales ESales
A 70 230
B 50 450
As given in the image below, enter the formula in cell B12 and drag to right and then down.
=LOOKUP(2,1/($A$2:$A$7=$A12),B$2:B$7)

remove mismatched rows in excel

I am having an excel file with 2000 records containing few columns like
A B C D E
114 5 270 product1 118
117 3 150 product1 190
118 9 300 product2 114
190 6 110 product1
191 11 540 product3
what I want to do is I want to remove the rows that are not matching the column A with E.
Expected Output
A B C D E
114 5 270 product1 114
118 9 300 product2 118
190 6 110 product1 190
Please help me
Assumption: your data table is in Sheet1, your Expected Output Table is in Sheet2.
Steps:
Copy column E of data table (DT) to column A of Expected Output Table (EOT).
Sort col A of EOT ascendingly (e.g. Data Ribbon > Sort & Filter).
Formula in B1 (EOT):
=Index(Sheet1!B$1:B$5, Match(Sheet2!$A1, Sheet1!$A$1:$A$5, 0), 1)
Above formula goes into the columns B to D in EOT.
Formula in E1 (EOT):
=$A1
The Index/Match would work even better if you had column headers. Then it would not matter whether the info from col B (DT) also goes into col B in EOT. Anyways, remember to adjust the ranges to your actual ones, and be careful with the $ signs.

Compare column A with column B and return minimum value in column A in Column C

Here is my table. I want to return the minimum value from column A in column C only if the values in Column B are equal.
A B C
1 Price Category Lowest Price Per Category
2 240 19
3 231 19 231
4 233 19
5 450 12
6 438 12
7 425 12 425
8 674 33
9 675 33
10 671 33 671
You could try the SUBTOTALfunction and use this formula in the column for lowest:
=IF(A2=SUBTOTAL(5;$A$2:$A$4);A2;"")
You would have to manually adjust the locked range ($A$2:$A$4) for every group though so that it matches the range for the group.
Or if your happy with getting the min value for each group on a separate row under every group you could just mark the two columns (including header row) and use the Subtotalbutton on the Data tab set like in this image:
Then the result would look something like this:
Price Category
240 19
231 19
233 19
231 19 Min
450 12
438 12
425 12
425 12 Min
674 33
675 33
671 33
671 33 Min
231 Grand Min
Try using this formula in C2 copied down
=IF(COUNTIFS(B:B,B2,A:A,"<"&A2),"",A2)
COUNTIFS here counts rows where the category matches and the price is lower than the current row. If there is no such row then the current row price must be lowest for that category and the price is returned.
If there are tied lowest prices within any category then they will all be shown

Resources