4 Replies Latest reply on Jan 14, 2020 11:50 AM by Cynda Jones

# If Then Statements with Calculations

I am trying to do a forecast but am not sure what is wrong with my calculated field.  I am new to Tableau and need some help.

Forecast for Furniture is 25% greater than sales, 50% greater than sales for Office Supplies and 100% greater than sales for Technology.  I have attached the workbook

• ###### 1. Re: If Then Statements with Calculations

Give this a try:

IF [Category] = 'Furniture' THEN [Sales]*1.25

ELSEIF [Category] = 'Office Supplies' THEN [Sales]*1.5

ELSEIF [Category] = 'Technology' THEN [Sales]*2 END

• ###### 2. Re: If Then Statements with Calculations

You're off to a good start, and using the right type of logic, but those are three separate statements providing 3 different answers all at the same time.

You just need to use an ELSEIF to transition to the next contingent statement. If it's one thing or another, you could also just use ELSE.

Hope that helps!

-Graham

• ###### 3. Re: If Then Statements with Calculations

Graham:

Many thanks for your help!  It worked perfectly.

I find tableau to be quite challenging as I do not have any SQL knowledge and have not written a lot of formulas.  All of this is still quite intimidating, but help from the community is giving me hope!  :-)

Cynda

• ###### 4. Re: If Then Statements with Calculations

Hi John:

It works!  Thank you so much!  The answer was much simpler than expected.

Cynda