Forum Discussion

g-wizard's avatar
g-wizard
Frequent Visitor
2 years ago

If/ElseIf Statements from Tableau

Hello, I am still very new to PBI.

Just had a question on how I should translate this to Dax?

 

IF [# of Days Remaining]<0
THEN "Past Expiration Date"
elseif [# of Days Remaining]>=0 and [# of Days Remaining]<=30
THEN "1 Month"
elseif [# of Days Remaining]>30 and [# of Days Remaining]<=60
THEN "2 Month"
elseif [# of Days Remaining]>60 and [# of Days Remaining]<=90
THEN "3 Month"
elseif [# of Days Remaining]>90 and [# of Days Remaining]<=180
THEN "6 Month"
elseif [# of Days Remaining]>180 and [# of Days Remaining]<=270
THEN "9 Month"
elseif [# of Days Remaining]>270
THEN "9+ Month "

EN

1 Reply

  • I would suggest using the SWITCH() function; something like the following:

    SWITCH(TRUE(), 
      [# of Days Remaining]<0, "Past Expiration Date",
      [# of Days Remaining]>=0 && [# of Days Remaining]<=30,"1 Month",
      // ... etc
    )