nested ifs with multiple sumifs based on changing criteria - excel

I am having trouble with this formula and would like to know if I am even building it in the correct order or how i can change it to get the desired result. Getting formula missing an opening or closing parenthesis error:
=IF(BH2="PPD TO FSC",SUMIFS('ALL BIDS'!R:R,'ALL BIDS'!D:D,BV2,'ALL BIDS'!E:E,I2,'ALL BIDS'!W:W,'DC TOOL'!U2,'ALL BIDS'!G:G,'DC TOOL'!V2,'ALL BIDS'!H:H,'DC TOOL'!M2),SUMIFS(FREIGHT!Z:Z,FREIGHT!Q:Q,'DC TOOL'!F2,FREIGHT!M:M,H2,FREIGHT!O:O,"PPD",FREIGHT!AA:AA,GRIDS!$U$3),IF(BH2="PPD TO GDC",SUMIFS('ALL BIDS'!R:R,'ALL BIDS'!D:D,F2,'ALL BIDS'!E:E,I2,'ALL BIDS'!W:W,'DC TOOL'!U2,'ALL BIDS'!G:G,'DC TOOL'!V2,'ALL BIDS'!H:H,'DC TOOL'!M2),SUMIFS(FREIGHT!Z:Z,FREIGHT!Q:Q,'DC TOOL'!F2,FREIGHT!M:M,H2,FREIGHT!O:O,"PPD",FREIGHT!AA:AA,GRIDS!$U$3))

Looks like you want 3 different possible SUMIFS, with the logic being as follows:
IF BH2 = "x" SUMIFS1, IF BH2 = "y" SUMIFS2 else SUMIFS3 so you need to write that like this:
=IF(BH2="PPD TO FSC",SUMIFS('ALL BIDS'!R:R,'ALL BIDS'!D:D,BV2,'ALL BIDS'!E:E,I2,'ALL BIDS'!W:W,'DC TOOL'!U2,'ALL BIDS'!G:G,'DC TOOL'!V2,'ALL BIDS'!H:H,'DC TOOL'!M2),IF(BH2="PPD TO GDC",SUMIFS('ALL BIDS'!R:R,'ALL BIDS'!D:D,F2,'ALL BIDS'!E:E,I2,'ALL BIDS'!W:W,'DC TOOL'!U2,'ALL BIDS'!G:G,'DC TOOL'!V2,'ALL BIDS'!H:H,'DC TOOL'!M2),SUMIFS(FREIGHT!Z:Z,FREIGHT!Q:Q,'DC TOOL'!F2,FREIGHT!M:M,H2,FREIGHT!O:O,"PPD",FREIGHT!AA:AA,GRIDS!$U$3)))

Related

2 nest if with different source data excel

I have 2 data sources and i want to lookup data using Vlookup by using unique ID,
1st data source will show "X" if the ID locate there,
2nd data source will show "Y" if the ID locate there,
the other responses of ID lookup will show nothing ""
Data source 1:
20000543
10056577
10032255
10008287
10011657
10008119
10008212
10007880
10052842
10007959
10062445
10011361
10008079
10008836
10007792
10052651
10007793
10047404
10007913
10007528
10008252
10007388
10007311
10057445
10036263
20004767
20004010
20001276
20010704
10039655
10062427
20010703
10048331
Data source 2:
20003695
20010673
10011463
10021645
10007439
20001123
10008276
10055885
10007718
10007587
10007364
10055257
10007651
10056216
10054797
10052500
10059984
10027674
10010153
10007808
10008182
10007763
10007428
10008102
10050130
10037579
10021909
10009539
10057979
I want to lookup value by using ID "10008102" which is locate in Data source 2 than it will show "Y" for final result,
How can I achieve this?
Much appreciate that.
Thank you
Please don't kill me for the overkill, but I came up with this:
=IF(IFNA(MATCH(A1,Sheet2!A$1:A$29,0),"N")="N","N","Y")
The story:
Match(...,...,0) searches for an exact match (hence the zero).
you need to look for a relative reference, like A1 (without dollarsigns), so that you can drag down and use another cell reference at any time
you need to look inside a fix array, like A$1:A$29, so that, when you drag down, you don't modify the array you're looking in.
Match() either gives a number or an #N/A error in case not found.
IFNA() translates #N/A to "N" (but there's no else-case in IFNA())
IF() has an else-case.
I'm inviting Excel wizards to come up with a simpler solution :-)
Do you possibly want to account for the value existing in both or none of the columns?
=IF(AND(COUNTIF(A:A,E2)>0,COUNTIF(B:B;E2)>0),"X&Y",
IF(COUNTIF(A:A,E2)>0,"X",
IF(COUNTIF(B:B,E2)>0,"Y",
"NONE")))

Excel Len function based on condition

I have two columns in my excel file.
Full ID Expected Result
159473A1 159473
159696A1 159696
160614A1 160614
43293J1A 43293
43293D1A 43293
43293A2B 43293
43293J2B 43293
43293B2B 43293
What i had tried :
=Left(A2,LEN(A2)-2)
159473
159696
160614
43293J
43293D
43293A
43293J
43293B
53202
But has you can see, I cant do that because I still have some characters in the expected results
43293J
43293D
43293A
43293J
43293B
How can I get my expected results in like the top example?
In B2 try:
=LEFT(A2,MATCH(FALSE,INDEX(ISNUMBER(MID(A2,ROW(A$1:INDEX(A:A,LEN(A2))),1)*1),),0)-1)
If you have access to DA-functions (O365), like SEQUENCE:
=LEFT(A2,MATCH(FALSE,ISNUMBER(MID(A2,SEQUENCE(LEN(A2)),1)*1),0)-1)
Note: If you are dealing with integers too, maybe to prevent possible errors through MATCH, you could use =LEFT(A2,MATCH(FALSE,ISNUMBER(MID(A2&"A",SEQUENCE(LEN(A2)+1),1)*1),0)-1)
So, very simple in the first instance:
But you have an issue with line 4... so this will help that:
IF(ISNUMBER(VALUE(LEFT(A3,LEN(A3)-2))),VALUE(LEFT(A3,LEN(A3)-2)),VALUE(LEFT(A3,LEN(A3)-3)))
This formula will work for you , remember to click Ctrl+Shift+Enter after pasting formula as its a matrix based formula
mention your email i can send you my workout
=LEFT(A2,IFERROR(MATCH(1,ISERR(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)*1)*1,),)-1)

Error with formula trying to use IF(AND with three conditions

I am trying to write a formula to evaluate all possible values in three cells and score them in another. Excel says that there is a problem with my formula, but I can't locate it. Your help is appreciated.
I am using IF(AND throughout my spreadsheet, but only with two values. Those formulas are accepted by Excel.
=IF(AND(B2="No",B3="Red",B5="No"),0,
IF(AND(B2="No",B3="Green",B5="No",2,
IF(AND(B2="No",B3="Blue",B5="No",3,
IF(AND(B2="No",B3="Yellow",B5="No",5,5,
IF(AND(B2="No",B3="Red",B5="Yes"),0,
IF(AND(B2="No",B3="Green",B5="Yes"),2,
IF(AND(B2="No",B3="Blue",B5="Yes",3,
IF(AND(B2="No",B3="Yellow",B5="Yes",5,
IF(AND(B2="Yes",B3="Red",B5="Yes",0,
IF(AND(B2="Yes",B3="Green",B5="Yes",1,
IF(AND(B2="Yes",B3="Blue",B5="Yes",2,
IF(AND(B2="Yes",B3="Yellow",B5="Yes",5,
IF(AND(B2="Yes",B3="Red",B5="No",0,
IF(AND(B2="Yes",B3="Green",B5="No",1,
IF(AND(B2="Yes",B3="Blue",B5="No",2,
IF(AND(B2="Yes",B3="Yellow",B5="No",3))))))))))))))))
Excel states "There is a problem with this formula".
You had a 5,5 where you should have had a 5 and where missing many ) to close the ANDs
=IF(AND(B2="No",B3="Red",B5="No"),0,
IF(AND(B2="No",B3="Green",B5="No"),2,
IF(AND(B2="No",B3="Blue",B5="No"),3,
IF(AND(B2="No",B3="Yellow",B5="No"),5,
IF(AND(B2="No",B3="Red",B5="Yes"),0,
IF(AND(B2="No",B3="Green",B5="Yes"),2,
IF(AND(B2="No",B3="Blue",B5="Yes"),3,
IF(AND(B2="No",B3="Yellow",B5="Yes"),5,
IF(AND(B2="Yes",B3="Red",B5="Yes"),0,
IF(AND(B2="Yes",B3="Green",B5="Yes"),1,
IF(AND(B2="Yes",B3="Blue",B5="Yes"),2,
IF(AND(B2="Yes",B3="Yellow",B5="Yes"),5,
IF(AND(B2="Yes",B3="Red",B5="No"),0,
IF(AND(B2="Yes",B3="Green",B5="No"),1,
IF(AND(B2="Yes",B3="Blue",B5="No"),2,
IF(AND(B2="Yes",B3="Yellow",B5="No"),3,""))))))))))))))))
But I think you can do this with a simpler formula:
=IFERROR(IF(B2 = "No",CHOOSE(MATCH(B3,{"Red","Green","Blue","Yellow"},0),0,2,3,5),IF(B5="Yes",CHOOSE(MATCH(B3,{"Red","Green","Blue","Yellow"},0),0,1,2,5),CHOOSE(MATCH(B3,{"Red","Green","Blue","Yellow"},0),0,1,2,3))),"")
You could put your logic in string form in one cell (say, F1):
0NOREDNO 2NOGREENNO 3NOBLUENO 5NOYELLOWNO 0NOREDYES 2NOGREENYES 3NOBLUEYES 5NOYELLOWYES 0YESREDYES 1YESGREENYES 2YESBLUEYES 5YESYELLOWYES 0YESREDNO 1YESGREENNO 2YESBLUENO 3YESYELLOWNO
Then your code reduces to:
=MID(F1, FIND(UPPER(B2&B3&B5),F1)-1, 1)
This would also make it extremely easy to add more conditions in the future.
Try this:
=IF(B3="Red",0,
IF(B3="Green",
IF(B2="Yes",1,
IF(B2="No",2,NA())),
IF(B3="Blue",
IF(B2="Yes",2,
IF(B2="No",3,NA())),
IF(B3="Yellow",
IF(AND(B2="Yes",B5="No"),3,5),
NA()))))
Hope that helps

How do I sum results of two if statements in the same cell?

I'm looking to have the results of two If statements calculated and added in the same cell. I'm getting #VALUE! error.
=IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))+IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
=IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
+
IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
Your both IF functions return an empty string "". Using + operator with strings returns #VALUE!. There are different methods to fix it:
use 0 instead of ""
use SUM instead of + (it ignores strings).
And as #John Bustos mentioned in his comment, you can simplify your formula with
IFERROR(value,value_if_error)
IFERROR description

How to write a compound IF statement checking two sets of two values

I know the title is confusing, but I can't figure our how to word it properly. I'm trying to figure out how to properly format a compound conditional in an IF statement in Excel. It's for a school project that's due tomorrow.
I already have something like this
=if(AND(b152="oval.jpg",c152="q'")OR(AND(b152="triangle.jpg", c153="p'")), "Correct", "Incorrect")
In psuedocode I want it to run something like this:
if (b152=="oval.jpg" && c152=="q'") or (b152=="triangle.jpg", c153="p'"):
print("YES!")
else
print("False!")
I know I'm missing something here. My current excel code returns false even if the conditions are true. Thanks ahead of time!
OR is a function in Excel, like AND. Try something like this:
=if(OR(AND(b152 = "oval.jpg", c152 = "q'"), AND(b152 = "triangle.jpg", c153 = "p'")), "Correct", "Incorrect")

Resources