Forum Discussion
Multiple nested IF statements
- 1 year ago
Hi tomekm ,
Please try the following DAX for your calculated column and replace 'Table' with the name of your table:Status = IF ( 'Table'[Total] > 0, SWITCH ( TRUE(), 'Table'[A] > 0 && 'Table'[B] > 0 && 'Table'[C] > 1 && 'Table'[D] > 1, IF('Table'[Customer Type] = "OK", "Primary", "Secondary"), 'Table'[A] > 0 && 'Table'[C] > 1 && 'Table'[D] > 0, IF('Table'[Customer Type] = "Upcoming", "Tertiary", "Advanced"), 'Table'[Customer Type] = "Other", "Basic", "Next" ), "No Access" )
The SWITCH() function in DAX acts the same as nested IF() statements. However, it is more performant and easier to manage.If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.
Thanks,Samson
Hi tomekm ,
Please try the following DAX for your calculated column and replace 'Table' with the name of your table:
Status =
IF (
'Table'[Total] > 0,
SWITCH (
TRUE(),
'Table'[A] > 0 && 'Table'[B] > 0 && 'Table'[C] > 1 && 'Table'[D] > 1,
IF('Table'[Customer Type] = "OK", "Primary", "Secondary"),
'Table'[A] > 0 && 'Table'[C] > 1 && 'Table'[D] > 0,
IF('Table'[Customer Type] = "Upcoming", "Tertiary", "Advanced"),
'Table'[Customer Type] = "Other", "Basic",
"Next"
),
"No Access"
)
The SWITCH() function in DAX acts the same as nested IF() statements. However, it is more performant and easier to manage.
If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.
Thanks,
Samson