I am trying to figure out the order of operations for a nested If Then Else statement, as my code is returning the incorrect answer. I have attached the workbook / example of what I am trying to achieve, but the detract_from_Savings is taking Savings Column 2 instead of Savings Column 1 ($20) - It should perform the If statement in bold, however it hits the statement before that and returns answer based on that.
Any help greatly appreciated.
If Contains([Detract_Savings_5], "Yes") and
[Dollars] < [Savings_5] then [Dollars] elseif [Dollars] >= [Savings_5] then [Savings_5]
Else (
If Contains([Detract_Savings_5], 'No') and [Detract_Savings_4] = "Yes" and
[Dollars] < [Savings_4] then [Dollars] elseif [Dollars] >= [Savings_4] then [Savings_4]
Else (
If Contains([Detract_Savings_5], 'No') and [Detract_Savings_4] = "No" and
[Detract_Savings_3] = "Yes"
and
[Dollars] < [Savings_3] then [Dollars] elseif [Dollars] >= [Savings_3] then [Savings_3]
Else (
If Contains([Detract_Savings_5], 'No') and [Detract_Savings_4] = "No" and
[Detract_Savings_3] = "No" and
[Detract_Savings_2] = "Yes"
and
[Dollars] < [Savings_2] then [Dollars] elseif [Dollars] >= [Savings_2] then [Savings_2]
Else (
If Contains([Detract_Savings_5], 'No') and [Detract_Savings_4] = "No" and
[Detract_Savings_3] = "No" and
[Detract_Savings_2] = "No" and
[Detract_Savings_1] = "Yes"
and
[Dollars] < [Savings_1] then [Dollars] elseif [Dollars] >= [Savings_1] then [Savings_1]
Else 0
Endif)
EndIf)
EndIF)
endif)
endif