Tableau - If elseif and Nested if (converting excel formula)

Опубликовано: 05 Октябрь 2024
на канале: Tableau Tip
1,693
6

NOTE: Instead of angle brackets != is used
Excel Formula:

=IF(A2=123, "Superfast", IF(B2="xyz","Express", IF(C2="mnp",IF(D2="abc","General","Oridnary"),"Other")))
SYNTAX IN EXCEL : IF(a!=b,TRUE,FALSE) eg: IF(4!=5,a,b) , output: a

Tableau calculation 1:
-----------------------------------
If [AA]=123 then 'Superfast'
Elseif [BB]='xyz' then 'Express'
Elseif [CC]='mnp' and [DD]='abc' then 'General'
Elseif [CC]='mnp' and [DD]!='abc' then 'Ordinary'
Elseif [DD]!='mnp' then 'Other'
End
Tableau calculation 2:
------------------------------------
If [AA]=123 then 'Superfast'
Elseif [BB]='xyz' then 'Express'
Elseif [CC]='mnp' then (if [DD]='abc' then 'General'
else 'Ordinary' End)
Else 'Other'
End

Data used:
AA BB CC DD Excel Formula
123 aaa mnp www Superfast
456 xyz aaa aaa Express
123 qqq mmm sss Superfast
12 xyx mnp www Oridnary
11 bbb mnp abc General
123 yyy qqq abc Superfast
1 2 3 4 Other