I am having difficulty figuring out the If statements with multiple conditions. I keep getting syntax errors.

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

I am writing a formula for calculating Worker's Comp estimates for a pricing tool. Example is below: 

IF([location - Address: State/Region] =”Alabama”) AND ([Labor/Mgmt] = ”Management”),[Annual Wages]*.0011,IF([location - Address: State/Region] =”Alabama”) AND ([Labor/Mgmt] = ”Labor”),[Annual Wages]*.012)

Photo of Jim

Jim

  • 40 Points

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,310 Points 50k badge 2x thumb
try this

IF(

[location - Address: State/Region] =”Alabama” AND [Labor/Mgmt] = ”Management”,[Annual Wages]*.0011,

[location - Address: State/Region] =”Alabama” AND [Labor/Mgmt] = ”Labor”,[Annual Wages]*.012)



note btw that this will be null if the conditions are not true.



 You may actually want this



IF(

[location - Address: State/Region] =”Alabama” AND [Labor/Mgmt] = ”Management”,[Annual Wages]*.0011,

[location - Address: State/Region] =”Alabama” AND [Labor/Mgmt] = ”Labor”,[Annual Wages]*.012, 0)
Photo of Jim

Jim

  • 40 Points
Thank you for the quick reply. I tried both scenarios and I am still getting a syntax error. Could it perhaps have something to do with the field types? I am creating a Formula-Numeric field (as I want it to return currency). Location is a field from the "address" function (connected via relationship), Labor/Mgmt is a drop down field from the same table, Annual Wages is a Formula-Numeric field. Thoughts?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,310 Points 50k badge 2x thumb
can you post your formula and the error?
Photo of Jim

Jim

  • 40 Points
IF(

[location - Address: State/Region] =”Alabama” AND [Labor/Mgmt] = ”Management”,[Annual Wages]*.0011,

[location - Address: State/Region] =”Alabama” AND [Labor/Mgmt] = ”Labor”,[Annual Wages]*.012)

----------------------------------------------------
Formula syntax error

Expected a valid expression after the "="


IF(

[location - Address: State/Region] =  ”Alabama” AND [Labor/Mgmt] = ”Management”,[Annual Wages]*.0011,

[location - Address: State/Region] =”Alabama” AND [Labor/Mgmt] = ”Labor”,[Annual Wages]*.012)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,310 Points 50k badge 2x thumb
The quotes around the word Alabama got copied in as the wrong kind of quotes.  Please retype them off your keyboard.  They cannot be the curly 66 99 type quotes. they need to be the quotes near the enter key.
Photo of Jim

Jim

  • 40 Points
That appears to have worked. How odd. Thank you!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,310 Points 50k badge 2x thumb
Once you have been bitten by curly quotes, you don't forget. I got bit once.