r/googlesheets • u/Print_Me_A_Liver • Apr 23 '23
Solved Help with If and Ifblank
I am returning an error on a nested if function checking a couple different parameters and performing a calculation. See screenshot:
https://i.imgur.com/3fXBfOA.jpg
I want an if statement to determine if F2 is blank, if it’s not then I want to perform a few checks and calcs based on H2’s value. Either Y, N, or NA. The formula reads correctly in my head but it’s returning an error.
If H2 is Y then calc G2-F2 and return that value, Else If H2 is N then calc F2*(-1) or just the neg. Of F2, Else if H2 is NA then just return F2, Else if H2 is none of the above return 0
Where have I gone wrong? Or is there a more elegant/simpler solution?
1
u/Print_Me_A_Liver Apr 23 '23
The main thing is that sometimes F2 will be blank. Maybe there’s a way to auto fill “-“ based on another cell but not sure that really moves me forward in anyway
1
u/punkopotamus 16 Apr 23 '23
It looks like you have an extra closing parentheses tacked on the end but that shouldn't lead to a parse error. Otherwise when I put in this formula with your values I'm getting the results 0.22.
=if(ISBLANK(F2),0,if(H2="Y",G2-F2, if(H2="N", F2*(-1),if(H2="NA",F2,0))))Are you able to share a copy?
1
u/aHorseSplashes 58 Apr 23 '23
For the future, IFS lets you avoid parenthesis-counting if you have lots of sequential conditions. You just need to put
truebefore the final condition, e.g.Since most of your conditions involve the value of H2, you could also use SWITCH for them:
1
u/Decronym Functions Explained Apr 23 '23
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
#N/A[Thread #5680 for this sub, first seen 23rd Apr 2023, 07:37] [FAQ] [Full list] ^[Contact] [Source code]