SUMPRODUCT with calculated criteria over column - excel

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.

Related

Check if there is at least one value in column C that is bigger then the value in Column B (without Helper Column)

A
B
C
D
1
Product
sales_volume
purchase_volume
Check
2
Product_A
500
400
yes
3
Product_B
600
700
4
Product_C
300
250
5
Product_D
800
620
6
Product_E
100
100
7
In Cell D2 I want to have a formula that is doing the following:
= If there is at least one value in Column C > value in Column B then "yes" else "no"
I know I could achieve this with a Helper Column that subtracts the values from both Columns and then check the Helper Column for values >= 0.
However, I would prefer a solution without a Helper Column.
Do you have any idea if this is possible?
=IF(SUM(IF(C2:C6>B2:B6, 1, 0))>0, "yes", "no")
Be warned this is an array formula so might required you to press Ctrl+Shift+Enter after typing the formula instead of just inserting it normally
If B2 is GREATER than the largest number in the range C2:C6, then "no", else "yes".
Try this formula in cell D2:
=IF(B2>MAX(C$2:C$6),"no","yes")
you can then drag the formula down to other cells

SUMIFS with mutliple OR/AND criterias (using a cell reference)

A B C D E F G E
1 Products Suppliers Value Criteria 1: Product_C Result: 600
2 Product_A Supplier_01 500 Criteria 2: Supplier_01
3 Product_B Supplier_01 600 Criteria 3: Supplier_03
4 Product_B Supplier_02 300
5 Product_C Supplier_01 200
6 Product_C Supplier_01 400
7 Product_C Supplier_03 800
8
9
In the table you find a list of different Products (Column A) and Suppliers (Column B).
In Cell G1 I want to get the sum of the values in Column C if the following conditions are met:
Product = Product_C AND
Supplier = Supplier_01 OR Supplier_03
Those conditions are typed in as Criteria 1-3 in Cells E1:E3.
In order to achieve this I tried to go with the solution from these questions (Q1,Q2) which gives me the correct result:
G1 =SUM(SUMIFS($C:$C,$A:$A,$E$1,$B:$B,{"Supplier_01","Supplier_02"}))
However, my issue with this solution is that I need to enter the OR-criterias manually as {"Supplier_01","Supplier_02"}. How do I have to change my formula so I can refer to the values in Cells E2:E3 so if the user changes those values the result is automatically adjusted?
One possibility:
=SUMPRODUCT((A2:A7=E1)*((B2:B7=E2)+(B2:B7=E3))*C2:C7)
It will be easy to extend criteria in the same fashion for both column A and B.
I was going to say that you need to transpose E2:E3. I think this is true in general, but in this particular case with only a single criterion applying to column A, you don't need to:
=SUM(SUMIFS($C:$C,$A:$A,$E$1,$B:$B,$E$2:$E$3))
works if entered as an array formula.
If you have multiple criteria for A and B, you do need to transpose one set of criteria:
=SUM(SUMIFS($C:$C,$A:$A,$E$1:$E$2,$B:$B,TRANSPOSE($E$3:$E$4)))
try this
=SUM(SUMIFS($C:$C,$A:$A,$E$1,$B:$B,E2:E3))
or
=SUM(IF(($A$2:$A$7=E1)*(($B$2:$B$7=E2)+($B$2:$B$7=E3)),$C$2:$C$7,0))

Excel: Conditional Formatting to colour Row based on two cells

Lets say I have a 4 x 5 table (below). Is there a way I can say if Date1 or Date2 > 30 days old (=today()-30) then colour these 4 cells dark blue.
Fruit Date 1 Date 2 Price
A 08/01/2020 05/01/2020 50
B 29/11/2019 24/12/2019 60
C 19/11/2019 09/11/2019 55
D 31/12/2019 29/12/2019 65
You can use following formula in conditional formatting:
=($B2+30<TODAY())+($C2+30<TODAY())

Excel Sumifs Index Match returning only value

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))

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))

Resources