Forum Discussion
Complex If Then Statement
- 6 years ago
Hi Anonymous
there are 2 options:
1. DAX using SWITCH()
Column = SWITCH(TRUE(), ISBLANK([Prosecution Date]) && ISBLANK([Court Date]), "Unknown", ISBLANK([Prosecution Date]) && NOT(ISBLANK([Court Date])), "Court", NOT(ISBLANK([Prosecution Date])) && ISBLANK([Court Date]), "Prosec", [Prosecution Date]>[Court Date], "Prosec", "Court" )2. Power QUery Custom Column
= if [Prosecution Date] = null and [Court Date] = null then "Unknown" else if [Prosecution Date] = null and [Court Date] <> null then "Court" else if [Prosecution Date] <> null and [Court Date] = null then "Prosec" else if [Prosecution Date] > [Court Date] then "Prosec" else "Court"
Hi Anonymous
there are 2 options:
1. DAX using SWITCH()
Column = SWITCH(TRUE(),
ISBLANK([Prosecution Date]) && ISBLANK([Court Date]), "Unknown",
ISBLANK([Prosecution Date]) && NOT(ISBLANK([Court Date])), "Court",
NOT(ISBLANK([Prosecution Date])) && ISBLANK([Court Date]), "Prosec",
[Prosecution Date]>[Court Date], "Prosec",
"Court"
)
2. Power QUery Custom Column
= if [Prosecution Date] = null and [Court Date] = null then "Unknown"
else if [Prosecution Date] = null and [Court Date] <> null then "Court"
else if [Prosecution Date] <> null and [Court Date] = null then "Prosec"
else if [Prosecution Date] > [Court Date] then "Prosec"
else "Court"
- Anonymous6 years agoNot applicable
I am fairly new to Power Bi does "[]" indicate a table? All of my variables are columns in one table.
- ChrisMendoza6 years agoResident Rockstar
Anonymous -
The documentation shows a nice explanation of syntax. https://docs.microsoft.com/en-us/dax/dax-syntax-reference.
- az386 years agoCommunity Champion
Anonymous
[] its a column name inside your table.
Table[Column] - full syntax
- Anonymous6 years agoNot applicable
Thank you so much! This has been so helpful.
Do you know how I culd use this new column in an if then statement sort of thing but using a DAX function instead? Like if = court then [Court Statement] if = Prosec then [Prosec Statement], else unknown.
I would do the if then in power query mode but working from home I lost access to the server adn can't update the data. So no power query for me today.