Sumproduct with mapping multiple rows and match through the rows - excel

want to write excel formula that will sum the values based on a match of the rows. The cells to be matched can occur multiple times and basing on the Mapping legend they should return the sum of values.
In the yellow cells I am trying to calculate sum of values in range B9:B21 based on a match of the names in G3:G8 according to Mapping legend to Item1, then Item2 and Item 3. Also I want to consider the sum to be done across Date 1, Date 2 and Date 3. The SumProduct formula below works only
if I use it on sum array for a single date but not across date1 , date2 and date 3:
Does sombody know how to fix this?
I would like to add that I want to have the fomrula to be identical in each yellow cell without splitting the arrays across the dates. The more, it is important in the formula to have it on the basis that 'date 1', 'date2' and 'date3' are matched.

Put this array formula into B2 with CSE then fill right and down.
=SUM(SUMIFS(INDEX($B$8:$D$19, 0, MATCH(B$1, $B$7:$D$7, 0)), $A$8:$A$19, IF($F$2:$F$7=$A2, $G$2:$G$7)))

Related

How to use SUMIF in an array formula to not sum blank rows

Hi I am using the following array formula to sum rows AC-AG , I would like to modify it so that it does not sum if an entire row is blank. How would I do this using an array formula since this spreadsheet is tied to a google forum and gets updates often.
I am using this formula at the top of the column.
={"# Boxes of Household Items"; ARRAYFORMULA(SUMIF(IF(COLUMN(AC1:AG1),ROW(AC2:AG)),ROW(AC2:AG),AC2:AG))}
Example Below
The Formula adds up AC through AG and puts them in AR.
I want the formula to not put a zero in AR5 since the entire row is blank
In the image above I have numbers in various cells from columns A:E, then I have a formula in cells F1:F3.
Row 1 has numbers for all cells.
Row 2 has numbers for some cells.
Row 3 has no numbers.
To show the sum when all/some of the cells contain numbers, I would do:
=IF(COUNT(A1:E1)>0,SUM(A1:E1),"")
We check IF there is at least one number using COUNT(A1:E1)>0. If there is at least one number, we then show the sum using SUM(A1:E1) otherwise we just show nothing, which is the "" part.
For you the formula would be this in AR2:
=IF(COUNT(AC2:AG2)>0,SUM(AC2:AG2),"")

Countif non blank based on date range

I'm looking for a way to count only the cell where based on the cell's date value it will check if the rest of the cells' values in the same row is 0 and will return the count.
So in the picture (cell: I2) I'm trying to return the count of those only who joined say within 2019 (A2:A12) and didn't receive any induction.
Desired answer
Where column A is the join date and Columns B through G are the possible introduction dates, you can just use IF with logical tests, drag the formula down, and then count the instances with SUM.
Try:
=IF(AND($A2>=1/1/2018, $A2<=12/31/2018, CONCAT($B2:$G2)=""), 1, "")

How do I sum a column based on multiple sets of OR criteria?

I have a table with a target sum column (ColA) and three columns to filter based on criteria. I've been using SUMIFS to calculate the sum of ColA based on the criteria columns Cols B through D however I notice I'm not doing this correctly.
One thing to note is that the criteria columns have varying amounts of criteria each (e.g. column B has more OR conditions than C)
My current formula is:
SUM(SUMIFS(table[ColA], table[colB], {"val1", "val2", "val3"}, table[colC], {"val1", "val2"}, table[colD], {"val1", "val2", "val3", "val4"}))
The result of this formula is incorrect after manually checking the sum in the underlying table. Any advice on how to sum a column based on a set of multiple OR values?
You will need to do a SUMPRODUCT which will get long:
=SUMPRODUCT(table[ColA]*
((table[colB]="val1")+(table[colB]="val2")+(table[colB]="val3")>0)*
((table[colC]="val1")+(table[colC]="val2")>0)*
((table[colD]="val1")+(table[colD]="val2")+(table[colD]="val3")+(table[colD]="val4")>0))
To understand, the * is the equivalent to AND, the + is equivalent to OR
Let's say your table is called Table1, starts in A1 with headers, and is 4 columns wide. In a cell somewhere to the right, let's say G2, you could enter this formula:
=AND(OR(B2={"val1","val2","val3"}),OR(C2={"val1","val2"}),OR(D2={"val1","val2","val3","val4"}))
leaving G1 blank, then your sum formula is just:
=DSUM(Table1[#All],1,G1:G2)
You could also break the criteria formula up into three cells, one for each column, using:
=OR(B2={"val1","val2","val3"})
=OR(C2={"val1","val2"})
=OR(D2={"val1","val2","val3","val4"})
in G2:I2 (either leave G1:I1 blank, or give them labels that do not match any of your table headers), then use:
=DSUM(Table1[#All],1,G1:I2)
You could try to use MATCH() nested in SUMPRODUCT():
Formula in F1:
=SUMPRODUCT(ISNUMBER(MATCH(B2:B6,{"Val1","Val2","Val3"},0)+MATCH(C2:C6,{"Val1","Val2"},0)+MATCH(D2:D6,{"Val1","Val2","Val3","Val4"},0))*A2:A6)

How to sum corresponding values with same month and names of two columns in Excel?

The formula should sum up the column C based on Column A and B when two column value matches and displays the sum value only in the first cell D2 of Column D as shown in figure "60" & "67".
I am trying with SUMIFS but not getting the Output as required.
=SUMIFS(C2:C6;A2:A6;"A:A";B2:B6)
Try this formula in cell D2:
=IF(SUMPRODUCT(--($A$2:$A2&$B$2:$B2=$A2&$B2))=1,SUMPRODUCT(--($A$2:$A$6&$B$2:$B$6=$A2&$B2),$C$2:$C$6),"")
It should give expected output.
It might also be better/more efficient if you create a helper column (which stores concatenation results, instead of doing the concatenation multiple times in each formula).

Countifs does not work when a range with multiple column is selected

I need a count if function that counts me the cells that meet a certain criteria. This should be done with countifs. The formula is the following:
=COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!K:Q;">=1")This formula returns me an value type error.
This formula works well until I introduce the last condition orders!K:Q;">=1"
I would like a formula that counts if the word Ecolab is present in the cell; if the date is after or equal 01/01/2019; if the column U has more or equal than the number 36 and if there is at least a "1" in the cells in the row from column K to column Q. I could do this by easily replicating the countifs several times, (i.e =COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!K:K;">=1")+COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!L:L;">=1")+...........+COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!Q:Q;">=1")
But I would rather not include such a long formula as it would create confusion for the ultimate user of the excel sheet
Per my comment above, you could use SUMPRODUCT (avoid using whole columns for that) or an array with OFFSET like this:
=SUM(COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";OFFSET(Orders!J:J;0;{1;2;3;4;5;6;7});">=1"))
If the count for K:Q should be 1 when there may be more than one cell greater or equal to 1 in a single row then you need to apply OR criteria in a SUMPRODUCT.
SUMPRODUCT formulas should not use full column references; there is too much wasted calculation. The following is for rows 2:99; adjust for your own use.
=SUMPRODUCT(--ISNUMBER(SEARCH("ecolab", Orders!D2:D99)),
--(Orders!B2:B99>=DATE(2019, 1, 1)),
--(Orders!U2:U99>=36),
SIGN((Orders!K2:K99>=1)+(Orders!L2:L99>=1)+(Orders!M2:M99>=1)+(Orders!N2:N99>=1)+(Orders!O2:O99>=1)+(Orders!P2:P99>=1)+(Orders!Q2:Q99>=1)))

Resources