9 Replies Latest reply on Aug 3, 2017 10:38 AM by Radi Saran

# If condition - column value look up

I have the following scenario:

I have two calculated fields and date column

NameSIGN DATECalc 1Calc 2Year Difference
AAA02/5/151321432
BBB2/4/171391450
CCC10/29/141421763

Now I have to create a formula where

if year difference < 1 , then calc3 = calc1

else calc 3 = calc 2

Desire output:

NameSign Datecalc 3
AAA02/5/15143
BBB2/4/17139
CCC10/29/14176

How can I do this in Tableau?

• ###### 1. Re: If condition - column value look up

Your calculation there is comparing calculations as a result of a clause, can you describe your desired result?

• ###### 2. Re: If condition - column value look up

Sorry if I wasnt clear. I just updated the question.

Thanks,

• ###### 3. Re: If condition - column value look up

Ah perfect, thanks!

Try:

IF [Year Difference] <=0 then [Calculation 1] ELSE [Calculation 3] END

• ###### 4. Re: If condition - column value look up

Do I create a calculated field called calculation 3?

• ###### 5. Re: If condition - column value look up

Calculation below will be named [Calculation 3]

IF [Year Difference] <=0 then [Calculation 1] ELSE [Calculation 2] END

1 of 2 people found this helpful
• ###### 6. Re: If condition - column value look up

Worked like a charm. But just that  had to use

IF attr([Year Difference]) <=0 then [Calculation 1] ELSE [Calculation 2] END

• ###### 7. Re: If condition - column value look up

But if i use this, the grand total calculation seems wrong. Any thoughts?