Excel Nesting IF in SumIfs - excel

Ok. So i'm looking to nest IF in my SUMIFS formulas. The only problem i'm having is when one of my referenced cells show FALSE, the formula no longer works. How do i get the formula to completely remove that Criteria from the SUMIFS formula and still work?
Codes i've used.
=SUMIFS(R:R,IF(BE4=TRUE,I:I),IF(BE4=TRUE,BD4),J:J,BD5)
=IF(BE4=TRUE,SUMIFS(R:R,I:I,BD4),0)+IF(BE5=TRUE,SUMIFS(R:R,J:J,BD5),0)
I've even tried breaking the SUMIFS formula into multiple cells, and using IF and INDIRECT to create a working code. Just keeps popping up with #REF error.
Here's that code
=INDIRECT(CONCATENATE(BK1,IF(BE2=TRUE,BK2,""),IF(BE3=TRUE,BK3,""),IF(BE4=TRUE,BK4,""),IF(BE5=TRUE,BK5,""),BK6))
Here's the code that didn't work before the IF.
=INDIRECT(CONCATENATE(BK1,BK2,BK3,BK4,BK5,BK6))
Any help would be greatly appreciated.
Thank you
Mock Sheet
https://www.dropbox.com/s/tl64vbsalcqxqdm/CriteriaIFS.xlsx?dl=0

Try this formula:
=SUMIFS(BK1:BK6,BK1:BK6,">=0")

Please try this formula,
=IF(BE4=TRUE,SUMIFS(R:R,I:I,BD4,J:J,BD5),SUMIFS(R:R,J:J,BD5))
Your formula
=SUMIFS(R:R,IF(BE4=TRUE,I:I),IF(BE4=TRUE,BD4),J:J,BD5)
You are saying:
Sum from column R everything if match in J with BD5 and IF BE4 is TRUE THEN in I IF match with BD5. Well, the error is because, if BE4 is true is returning a string not a range. Instead you could use this:
=SUMIFS(R:R,INDIRECT(IF(BE4=TRUE,I:I)),INDIRECT(IF(BE4=TRUE,BD4)),J:J,BD5)
And it will be ok, until BE4 is FALSE. because the INDIRECT function return an #REF!... and will be a mess.
I'm not sure if I get the whole idea, but please tell me if you need an emprovement.
Edit #1
Reading your comments I think this could help:
=IF(BE4=TRUE,SUMIFS(R:R,I:I,BD4),0)+IF(BE4=TRUE,SUMIFS(R:R,J:J,BD5))
Try to post some dummie database (using text table format) to give you a better help... and remember to read this: How to ask because your question is to vague, and it was necesary to many comments and answers to "guess" what you really want.

Try this array formula:
=SUMIFS(N:N,IF($A$2,E:E,T:T),IF($A$2,$C$2,""),IF($A$3,F:F,T:T),IF($A$3,$C$3,""),IF($A$4,H:H,T:T),IF($A$4,$C$4,""),IF($A$5,I:I,T:T),IF($A$5,$C$5,""))
It is an array formula and must be confirmed with Ctrl-Shift-Enter.
This is based on your data sheet provided. You will need to change the references to your sheet. The column T reference should be a column that is empty.

I needed to do the same thing. The formula needed to look at a different column as Criteria_Range2 depending on product. I put an IF statement for both the Criteria_Range2, and for the Criteria2 because each column had slightly different information. Basically, it tells the formula use column C (in another worksheet) as the Criteria_Range2 if the product category is anything other than Ceilings. If it is Ceilings, it uses column A as Criteria_Range2. On my worksheet, Column A is a "helper column" that groups our Ceilings sub-products into Tile and Grid.
Hopefully this isn't too confusing, but it works for me and I didn't easily find anything else out there showing how to use IF statements in the Criteria Ranges in the SUMIFS. (I suggest ignoring the very ugly xlookup defining the sum_range.)
SUMIFS(XLOOKUP($AF$20&"COGS CM MTD",Fact_Sales!$E$6:$CS$6&Fact_Sales!$E$7:$CS$7,Fact_Sales!$E$8:$CS$928),Fact_Sales!$B$8:$B$928,'Report Draft'!$AE27,IF('Report Draft'!$AD27<>"CEILINGS",Fact_Sales!$C$8:$C$928,Fact_Sales!$A$8:$A$928),IF('Report Draft'!$AD27<>"CEILINGS",'Report Draft'!$AD27,'Report Draft'!$AF27))

Related

Use of Excel formula 'IF" and "AND" with multiple sheet to combine the data

I have two excel datasheets i.e. 'Data' and 'Sheet1'. Now, I am using the following excel formula to bring some data from 'Sheet1' to 'Data':
=IF(AND(Data!B2=Sheet1!A2,Data!C2="Argentina"),Data!AU2:CR2=Sheet1!B2:AY2,NAN)
The formula return "#NAME?".
Can you help solve this issue? Thanks in advance.
You no need to mention destination sheet cells in formula. If function doesn't accept this. Try below formula
=IF(AND(Data!B2=Sheet1!A2,Data!C2="Argentina"),Sheet1!B2,"NAN")
This is advise too large to fit into a comment:
In order to solve such an issue, you can use Formula auditing: it gets into your formula and solves it step by step.
After some evaluations, I get the question to evaluate this formula:
=IF(FALSE, Data!AU2:CR2=Sheet1!B2:AY2, NAN)
And the moment it wants to evaluate Data!AU2:CR2=Sheet1!B2:AY2, I get an error.
I tried to put this formula excerpt as a single formula into a sheet, and as a result I got a complete row, filled with boolean values (which does not fit into one single cell, explaining the problem).
What are you trying to do here? Do you want every single value to be equal? Do you want matches? ...

Excel Sumifs with multiple arrays referenced on another cell

I have a formula that sums one column based on a criteria from another column. This formula works fine:
=SUM(SUMIFS(sheet1!C:C,sheet1!A:A,{1, 7}))
However, i need to be able to use a cell reference which will contain the {1, 7}
So the formula will look like this:
=SUM(SUMIFS(sheet1!C:C,sheet1!A:A,M2))
But this returns a zero, when evaluting the formula it pulls the contents from the cell but wraps it in "" which i think is where the issue is happening.
I've tried adding formula to remove the quotes, and trying to pull the contents differently, but still the same.
Any help would be greatly appreciated.
Figured out a way round this.
I created a named range called condition, and assigned =Evaluate($M2).
Then I used this formula =SUMPRODUCT(SUMIFS(sheet1!C:C,sheet1!A:A,Condition))
This picks up all numbers used in M2, and works on all rows below with the Evaluate formula following.
Thank you to everyone that assisted with this.
This link helped aswell: Excel SUM of SUMIF/SUMIFS with dynamic multiple criteria

Get value using INDEX and MATCH

I need help in my formula, I'm getting #VALUE!.
I have 2 sheets, I need to get the data using 2 values, So I've searched and the solution is to use the INDEX and MATCH Function. I've tried that in my formula but I think I'm doing it wrong.
I have 3 columns in my Main Sheet,
In the column Total Amount I need to insert the formula.
And this is my 2nd sheet. 3 columns also.
And this is the formula that I've used,
=INDEX(Q9:Q13,MATCH(O19&P19,O9:O13&P9:P13,0))
I've tried to check using evaluate formula and I'm getting #Value! I don't know why.
Any Ideas?
Thanks!
I think SUMIF() would be best fit for you in this case. Try below formula.
=SUMIFS(Sheet2!$Q$8:$Q$13,Sheet2!$O$8:$O$13,A1,Sheet2!$P$8:$P$13,B2)
You can also use SUMPRODUCT() like below.
=SUMPRODUCT((Sheet2!$Q$8:$Q$12)*(Sheet2!$O$8:$O$12=A2)*(Sheet2!$P$8:$P$12=B2))

Working SUMPRODUCT function on Google Sheets does not work in Excel

I have a function here that is meant to calculate how many leads I have in each country.
=sumproduct($A2=(vlookup(id_leads!$A:$A,country_leads!$A:$B,2,0)))
On sheet id_leads,$A:$A contains the lead ids
On sheet country_leads Column A contains the lead ids. Column B contains the country of which the lead is located.
Can someone explain why it fails in Excel (I get a #VALUE! error), but works fine in Google Sheets? A suggestion to make this formula work in Excel would be appreciated. I've tried to use COUNTIF and SUMIF, but couldn't figure it out.
Thanks in advance!
You need to use COUNTIFS() wrap by SUM() in an array formula, something like:
=SUM(COUNTIFS(D:D,B1:B3,E:E,A1))
Being an array it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.
Note the 2nd and 4th criteria need to be limited to the data set and not a full column reference.
So your formula would be something like this:
=SUM(COUNTIFS(country_leads!$A:$A,id_leads!$A1:$A100,country_leads!$B:$B,$A1))

Excel formula returns #value when named

I am working with the following table in Excel:
The following formula in evaluates normally when entered directly into a cell:
=DATE(YEAR(DATEVALUE($A$1)),MONTH(DATEVALUE($A$1)),DAY(INDIRECT(ADDRESS(2,COLUMN()))))
However, when I try to place put this in the named function test and call =test in another cell it returns a #VALUE! error. The best answer I have come up with after researching is that named formulas and the indirect function are not always compatible.
If anyone can shed some light to help explain what I am doing wrong or why I can not put an indirect call inside of a named range I would greatly appreciate it!
Yes, I don't believe INDIRECT will work with a named range - you shouldn't really need such a convoluted formula - try just
=(C$2&$A$1)+0
format as date
Edit: as per comments below, INDIRECT is OK but I don't think COLUMN() is liked in the named range. ROW and COLUMN functions sometimes behave badly because they return "arrays" even when single values, so you need another function like MAX or SUM to convert {2} to 2, e.g.
=DATE(YEAR(DATEVALUE($A$1)),MONTH(DATEVALUE($A$1)),DAY(INDIRECT(ADDRESS(2,MAX(COLUMN())))))
although I think there are shorter methods as I indicated above....

Resources