βMar 01, 2022 11:17 AM
I currently have the following IF nested statement. I donβt get an error when saving, but it only works when the first IF is found (13) and produces nothing for a result when the other two are in the identified field to check.
Am I missing a key element to make the βfalseβ portions of each IF statement work with a new nested IF statement?
IF({β Extender Weeks}=13, SUM({π WEEKS in Program (26 = 6mo)}+13, IF({β Extender Weeks}=9, SUM({π WEEKS in Program (26 = 6mo)}+9, SUM({π WEEKS in Program (26 = 6mo)}+4)))))
Solved! Go to Solution.
βMar 01, 2022 02:26 PM
Ooooβ¦
I donβt know how I missed that last portion of the formula!
If you wanted to add the last layer to account for the + 4 weeks, then it would look like this:
IF(
AND(
{β Extender Weeks},
{π WEEKS in Program (26 = 6mo)}
),
IF(
{β Extender Weeks} = 13,
{π WEEKS in Program (26 = 6mo)} + 13,
IF(
{β Extender Weeks} = 9,
{π WEEKS in Program (26 = 6mo)} + 9,
IF(
{β Extender Weeks} = 4,
{π WEEKS in Program (26 = 6mo)} + 4
)
)
),
"β Missing Key Data!"
)
Now, regarding the AND function as the conditional, nothing really changes beyond the fact that weβve just added a new layer to the IF nesting.
Itβs possible that Iβve misread your question about the AND statement, so please let me know if it went over my head.
Functionally, the formula will now just continue up the layers of 13, 9, and 4.
With that being said, I had something cross my mind when I was previously working on the original post.
(I want to clarify that I tend to write things out like this because they tend to be extremely valuable for people that might go searching for help when they run into problems. So apologies if I seem like I presume you donβt know whatβs happening.)
Are you using a single select field for the Extender Weeks field? Or are you using a text field?
If youβre using a single select field, then you donβt have to worry about scenarios where the Extender Weeks field will have any other value besides those three options.
However, if youβre using a text/number field, I had a slight concern about the behavior of the formula.
Now hereβs a scenarioβ¦
Both fields (Extender Weeks & Weeks In) are both filled in.
However, letβs say that Extender Weeks, despite being filled in, doesnβt have any of 13,9, or 4.
If this happens, the formula will just return null/blank.
This happens because the formula executed the truthy block, which is the nested IF statements.
But if none of the nested IF statements return true, then at the end of the last IF (the one that checks if it equals 4), the formula does nothing because we havenβt defined any actions for falsey conditions.
The syntax is written as:
IF(
{Condition 1},
{Action if Truthy},
{Action if Falsey}
)
But something about how IF statements generally work, is that the Falsey block is actually optional.
You can think of this asβ¦
IF(
{Condition 1},
{Action if Truthy}
)
In this example, if the condition returns falsey, then it will just return nothing.
If you look at the formula I provided you and pull apart the first action, you have three IF statements.
Each of them has a condition and an action if the conditions returns true.
However, none of them have a falsey block, so if Extender Weeks = 2, then it will just return blank.
So, letβs say you want to create some sort of message that lets you know something ainβt right.
In order to do this, you can use this formula structure:
1 IF(
2 AND(
3 {β Extender Weeks},
4 {π WEEKS in Program (26 = 6mo)}
5 ),
6 IF(
7 {β Extender Weeks} = 13,
8 {π WEEKS in Program (26 = 6mo)} + 13,
9 IF(
10 {β Extender Weeks} = 9,
11 {π WEEKS in Program (26 = 6mo)} + 9,
12 IF(
13 {β Extender Weeks} = 4,
14 {π WEEKS in Program (26 = 6mo)} + 4,
15 "Example Message!"
16 )
17 )
18 ),
19 "β Missing Key Data!"
20 )
Everything is the same here, except for that very last IF statement.
Here it is without all the noise:
IF(
{β Extender Weeks} = 4,
{ π WEEKS in Program (26=6mo)} + 4,
"Example Message!"
)
Here, if Extender Weeks isnβt 4, then the formula will return the Example Message!
text.
It looks like this:
Just food for thought and me being bored.
Again, let me know if you have any questions or think Iβm insane and scratching at the walls.
βMar 01, 2022 12:11 PM
Hey @Cole_Wedemeier!
Here is my revised version of your formula.
IF(
AND(
{β Extender Weeks},
{π WEEKS in Program (26 = 6mo)}
),
IF(
{β Extender Weeks} = 13,
{π WEEKS in Program (26 = 6mo)} + 13,
IF(
{β Extender Weeks} = 9,
{π WEEKS in Program (26 = 6mo)} + 9
)
),
"β Missing Key Data!"
)
Hereβs how it worksβ¦
Both the Extender Week and Weeks in Program fields must have data in them in order for the formula to work.
If both fields have data in them, then the following will happen:
If both fields are empty or return a falsey value, then a β Missing Key Data!
message will return. You can edit that message or remove it if youβd like.
If youβre curious about what I changed and why it behaves the way it does, or why your original formula wasnβt working as intended, please feel free to fire off a reply and Iβd be happy to explain it in-depth.
The same is true for any general questions or help!
βMar 01, 2022 01:24 PM
Wonderful! If I wanted to take that to the last level that I originally had, where the 3rd level of my original formula was that if the first two IF statements were both FALSE (as in it didnβt equal 13 or 9 for Extender Weeks) then it should do sum of Weeks in Program + 4 what does that look like when working with the AND added in for the very start?
Thank you so much.
βMar 01, 2022 02:26 PM
Ooooβ¦
I donβt know how I missed that last portion of the formula!
If you wanted to add the last layer to account for the + 4 weeks, then it would look like this:
IF(
AND(
{β Extender Weeks},
{π WEEKS in Program (26 = 6mo)}
),
IF(
{β Extender Weeks} = 13,
{π WEEKS in Program (26 = 6mo)} + 13,
IF(
{β Extender Weeks} = 9,
{π WEEKS in Program (26 = 6mo)} + 9,
IF(
{β Extender Weeks} = 4,
{π WEEKS in Program (26 = 6mo)} + 4
)
)
),
"β Missing Key Data!"
)
Now, regarding the AND function as the conditional, nothing really changes beyond the fact that weβve just added a new layer to the IF nesting.
Itβs possible that Iβve misread your question about the AND statement, so please let me know if it went over my head.
Functionally, the formula will now just continue up the layers of 13, 9, and 4.
With that being said, I had something cross my mind when I was previously working on the original post.
(I want to clarify that I tend to write things out like this because they tend to be extremely valuable for people that might go searching for help when they run into problems. So apologies if I seem like I presume you donβt know whatβs happening.)
Are you using a single select field for the Extender Weeks field? Or are you using a text field?
If youβre using a single select field, then you donβt have to worry about scenarios where the Extender Weeks field will have any other value besides those three options.
However, if youβre using a text/number field, I had a slight concern about the behavior of the formula.
Now hereβs a scenarioβ¦
Both fields (Extender Weeks & Weeks In) are both filled in.
However, letβs say that Extender Weeks, despite being filled in, doesnβt have any of 13,9, or 4.
If this happens, the formula will just return null/blank.
This happens because the formula executed the truthy block, which is the nested IF statements.
But if none of the nested IF statements return true, then at the end of the last IF (the one that checks if it equals 4), the formula does nothing because we havenβt defined any actions for falsey conditions.
The syntax is written as:
IF(
{Condition 1},
{Action if Truthy},
{Action if Falsey}
)
But something about how IF statements generally work, is that the Falsey block is actually optional.
You can think of this asβ¦
IF(
{Condition 1},
{Action if Truthy}
)
In this example, if the condition returns falsey, then it will just return nothing.
If you look at the formula I provided you and pull apart the first action, you have three IF statements.
Each of them has a condition and an action if the conditions returns true.
However, none of them have a falsey block, so if Extender Weeks = 2, then it will just return blank.
So, letβs say you want to create some sort of message that lets you know something ainβt right.
In order to do this, you can use this formula structure:
1 IF(
2 AND(
3 {β Extender Weeks},
4 {π WEEKS in Program (26 = 6mo)}
5 ),
6 IF(
7 {β Extender Weeks} = 13,
8 {π WEEKS in Program (26 = 6mo)} + 13,
9 IF(
10 {β Extender Weeks} = 9,
11 {π WEEKS in Program (26 = 6mo)} + 9,
12 IF(
13 {β Extender Weeks} = 4,
14 {π WEEKS in Program (26 = 6mo)} + 4,
15 "Example Message!"
16 )
17 )
18 ),
19 "β Missing Key Data!"
20 )
Everything is the same here, except for that very last IF statement.
Here it is without all the noise:
IF(
{β Extender Weeks} = 4,
{ π WEEKS in Program (26=6mo)} + 4,
"Example Message!"
)
Here, if Extender Weeks isnβt 4, then the formula will return the Example Message!
text.
It looks like this:
Just food for thought and me being bored.
Again, let me know if you have any questions or think Iβm insane and scratching at the walls.
βMar 01, 2022 04:14 PM
@Ben.Young I LOVE this full-out explanation!
So the βExtender Weeksβ is a # field that is populated on zapier automation and a βstop signβ icon to indicate to the team in the company to NOT TOUCH :slightly_smiling_face: Theyβre pretty great about that too.
However, I do like the addition of the message as a just-in-case.
I applied your updated formula to account for the +4, but now, every single record populates with your β :warning: Missing Key Data!β message at the end of the formula. If I take that last bit out, I get nothing returned for results in the field at all. :thinking:
βMar 01, 2022 04:25 PM
@Cole_Wedemeier - Hereβs a viewing link to the base Iβve been experimenting with.
Feel free to copy the base and play with the behavior.
I added a quick description app that also holds the formula as well.
My recommendation in situations like this is to delete the formula field youβve been working with previously.
Go through the formula I provided and make sure that all the field names are 100% accurate to whatβs in your base.
Formulas are weird.
Airtable can be weird.
Put the two together and you get something thatβs justβ¦ strange.
βMar 02, 2022 05:46 AM
Ah! It was a matter of having the row #'s in the quote copied in. Thank you so much! Truly appreciate all of your thought-out explanations and assistance.