Excel Sumifs Index Match returning only value - excel

Trying to use a combination of SUMIFS, INDEX and MATCH but the formula only returns a value from the first column and ignores subsequent columns which share the same field. What formula can I use to overcome this issue please?
A B C D E F
1 Name Week1 Week1 Week2 Week2 Year
2 CustomerA 10 20 30 40 2019
3 CustomerB 50 60 70 80 2019
4 CustomerA 90 100 110 120 2018
5 CustomerB 130 140 150 160 2018
I have to get the Week 1 Total for Customer A in 2019.
I tried using this formula:
=SUMIFS(INDEX(B:E,0,MATCH("Week1",B1:E1,0)), A:A,"CustomerA", F:F, "2019")
The formula however, only returns $10 for Customer A in Week 1 in 2019 instead of $30 ($10 from Cell B2 + $20 from cell C2). This means it matches the Week 1 field in column B and ignores the Week 1 field in column C.
What amendment do I need to make to the formula to overcome this problem please?
Thanks.

That method will only work if the values are unique, as it will only return the first column where a match is found.
You will need SUMPRODUCT:
=SUMPRODUCT(($B$1:$E$1="Week1")*($A$2:$A$5 = "CustomerA")*($F$2:$F$5 = 2019)*($B$2:$E$5))

Related

How to calculate averages IDs in Excel

I have the following data
A B
ID Time
22 00:20
33 00:30
60 01:30
41 00:20
41 00:30
33 01:00
22 01:00
Column A= Id and column B= Time
I want to calculate the average time for IDs and get the following table in Excel
I struggled to do it
C D
ID Time
22 40
33 45
60 90
41 25
Make sure you are using the right formula and have the number format as general.
If you have the unique IDs in column C, and want the average on column D, and row 1 has the titles, you could use this formula in cell D2:
=averageifs(b$1:b$1000, a$1:a$1000, d2)
It means "Average the number in column B if what is in column A matches D2".
Fill down the formula.
Then select column D, press Ctrl-1 (with the numbers on top of the letters) to go to format, and in "General" type [mm].
AVERAGEIF is enough:
=AVERAGEIF(A:A;D2;B:B)
Cell format [mm]

SUMPRODUCT with calculated criteria over column

Excel-Table:
A B C D E F G H
1 Products Date Sales Criteria 1: Product_B Result: 200
2 Product_A 2020-04-15 500 Criteria 2: 2020-04-15
3 Product_B 2020-04-12 600
4 Product_B 2020-04-12 300
5 Product_B 2020-04-15 200
6 Product_B 2020-04-20 400
7 Product_C 2020-04-15 800
8 Product_C 2020-04-19 900
9 Product_C 2020-04-30 300
10
11
In the table above I have different products and their sales on a certain date.
In Cell G1 I calculate sum of the sales based on the criterias in Cell E1 and E2.
G1 = SUMPRODUCT((($A$2:$A$100=$E$1)*($B$2:$B$100=$E$2)*$C$2:$C$100))
All this works exactly as it should.
Now, I want to change the date condition in the formula in Cell G1:
If in Column B a date + 3 days matches with the date in Cell E2 it should be considered in the sum for Cell G1.
Expected Result in Cell G1 would be 900.
How do I need to modify the SUMPRODUCT formula in Cell G1 to use the calculated criteria date + 3 days = E2 over Column B?
= SUMPRODUCT((($A$2:$A$100=$E$1)*($B$2:$B$100=($E$2-3))*$C$2:$C$100))
You could try:
=SUMIFS($C$2:$C$9,$A$2:$A$9,$E$1,$B$2:$B$9,$E$2-3)
$C$2:$C$9: The range with the Sales
$A$2:$A$9: The range with the Products
$E$1: Product as criteria
$B$2:$B$9: The range with the Dates
$E$2-3: Date as criteria
Also you could use the SUMPRODUCT
=SUMPRODUCT(($A$2:$A$100=$E$1)*($B$2:$B$100=$E$2-3)*($C$2:$C$100))
Note:
I think you use too many brackets in your formula. Enclose each Array in brackets and one set of brackets for the whole formula.

Find column and row name based on search criteria

I have the following Excel spreadsheet:
A B C D E F G
1 Q1 Q2 Q3 Q4 Search criteria: 60
2 Asset 1 15 85 90 70 Column name: Q4
3 Asset 2 40 80 45 60 Row name: Asset 2
4 Asset 3 30 50 55 10
5
In Cells A1:E4 I have different assets with their performance from quarter Q1-Q4.
In Cell G2 and G3 I want that the assets and the quarter are displayed based on the value that is put in Cell G1. In this case the search criteria is 60 so the result is column name Q4 and row name Asset 2.
With VLOOKUP or INDEX & MATCH I would only be able to find the the value 60 based on the criterias in Cell G2 and G3 but not the other way around like I need it.
Do you have any idea of a formula that could solve this issue?
NOTE: All values in the table are unique.
You could use something like this (entered as array formulas using Ctrl+Shift+Enter)
Try the following...
G2:
=INDEX(B1:E1,MATCH(G1,INDEX(B2:E4,MATCH(G3,A2:A4,0),0),0))
G3, confirmed with CONTROL+SHIFT+ENTER:
=INDEX(A2:A4,SMALL(IF(B2:E4=G1,ROW(A2:A4)-ROW(A2)+1),1))

Sorting values of a selectable month

I have the following Excel spreadsheet:
A B C D E
1 January February March February
2 Product A 500 300 800 500
3 Product B 400 500 250 300
4 Product C 600 100 700 100
In Columns A:C you can see the sales of three different products.
In Column E the user can select a month in Cell E1.
Based on this month the sales should be listed ascending.
I think this requires something like a VLOOKUP combined with a LARGE function since the matrix from the LARGE function has to switch based on the month in Cell E1.
Do you have any idea how I could achieve this?
You could use HLOOKUP to locate the month in E1 in the range B1:D1, but this just gives the value of the month ("February") and you need the position of the month (from 1 to 3) to find the right column B,C or D so I suggest using Index and Match as follows
=IFERROR(LARGE(INDEX($B$2:$D$4,0,MATCH($E$1,$B$1:$D$1,0)),ROWS($1:1)),"")

Index & Match formula using IF and ISERROR

I have data in columns C & D. A range of ten students in A1 to A10 are identified with roll numbers. In Column C and corresponding Column D, there are 8 students from roll number 1 to 8 (Column C) and their marks (Column D).
I need a formula in column B to automatically extract the marks from column D against the roll numbers in Column A and the two cells in column B (marks of roll number 9 & 10) may remain blank.
Any Excel formula or VBA macro solution is much appreciated.
Column-A Column-B Column-C Column-D
1 50 1 50
2 55 2 55
3 35 3 35
4 60 4 60
5 78 5 78
6 45 6 45
7 39 7 39
8 82 8 82
9
10
Try using VLOOKUP with IFERROR, i.e. this formula in B2 copied down
=IFERROR(VLOOKUP(A2,C$2:D$9,2,0),"")
VLOOKUP will return the required marks when the roll number exists.....or an error which IFERRORconverts to a blank.
The simplest solution would seem to be copy and paste. Alternative solutions would seem to be relatively simple (eg #barry's) but if you really want INDEX, MATCH, IF and ISERROR then maybe:
=IF(ISERROR(INDEX(D:D,MATCH(A2,C:C,0))),"",INDEX(D:D,MATCH(A2,C:C,0)))

Resources