Forum Discussion
Rewrite Tableau to DAX
Any help yall can provide when rewriting this Tableau Calc Column to DAX is appreciated. I have been struggling using Switch(True() and combinations of && ||
IFNULL(IF ([Column1] = 1 OR [Column2] = 1)
AND([Column3] = 1
OR [Column4] = 1
OR [Column5] = 1
OR [Column6] = 1
OR [Column7] = 1)
AND [Column8] = 0
THEN 'A&C'
ELSEIF ([Column1] = 1 OR [Column2] = 1)
AND([Column3] = 0
AND [Column4] = 0
AND [Column5] = 0
AND [Column6] = 0
AND [Column7] = 0)
AND [Column8] = 0
THEN 'A Only'
ELSEIF ([Column1] = 0 OR [Column2] = 0)
AND([Column3] = 1
OR [Column4] = 1
OR [Column5] = 1
OR [Column6] = 1
OR [Column7] = 1)
AND [Column8] = 0
THEN 'C Only'
ELSEIF [Column8] = 1
THEN 'NIAN'
END, 'NIAN')
8 Replies
- JamesFR06
Resolver IV
HI
IF(
ISBLANK(
IF(
OR([Column1] = 1, [Column2] = 1),
AND(
OR([Column3] = 1, [Column4] = 1, [Column5] = 1, [Column6] = 1, [Column7] = 1),
[Column8] = 0
),
""
)
),
IF(
ISBLANK(
IF(
OR([Column1] = 1, [Column2] = 1),
AND(
[Column3] = 0,
[Column4] = 0,
[Column5] = 0,
[Column6] = 0,
[Column7] = 0,
[Column8] = 0
),
""
)
),
IF(
ISBLANK(
IF(
OR([Column1] = 0, [Column2] = 0),
AND(
OR([Column3] = 1, [Column4] = 1, [Column5] = 1, [Column6] = 1, [Column7] = 1),
[Column8] = 0
),
""
)
),
IF([Column8] = 1, "NIAN", "NIAN"),
"C Only"
),
"A Only"
),
"A&C"
)- lang22Frequent Visitor
Why is Switch and True not something you are using? It's not a requirement ovbiously, just curious
- lang22Frequent VisitorAvC =RETURNSWITCH (TRUE (),(C1 = "1" || C2 = "1") &&(C3= "1" ||C4 = "1" ||C5 = "1" ||C6 = "1") && C7 = "0","AC",(C1 = "1" || C2 = "1") &&(C3 = "0" &&C4 = "0" &&C5 = "0" &&C6 = "0") && C7 = "0","A Only",(C1 = "0" || C2 = "0") &&(C3 = "1" ||C4 = "1" ||C5 = "1" ||C6 = "1") && C7 = "0","C Only",C7 = "1","Nian","Nian")
- Dangar332
Resident Rockstar
hi, lang22
not sure but try below code for new column
IF( [c1]=1||[c2]=1, IF( [c3]=1||[c4]=1||[c5]=1||[c6]=1||[c7]=1, IF( [c8]=0,"A&c",if( [c1]=1||[c2]=1,IF([c3]=0 &&[c4]=0&& [c5]=0 &&[c6]=0 && [c7]=0&&[c8]=0,"A only"), if([c1]=0||[c2]=0,IF([c3]=1||[c4]=1||[c5]=1||[c6]=1||[c7]=1&&[c8]=0,"C only",IF([c8]=1,"Nian")))))))here just repale c with column in your code
- lang22Frequent Visitor
Why is Switch and True not something you are using? It's not a requirement ovbiously, just curious
- Dangar332
Resident Rockstar
hi, lang22
because in switch function dependencies for previous condition not relate with current condition.
and here in your case currunt condition depend on previous conditions that's why I prefer nested if condition.switch() use when you not need to take look previous condition means your current condition is independent of other condition.
we can also use combination of switch() and if() function .i hope you cleasr about it