Forum Discussion
drrai66
8 years agoResolver I
Calculated Column with multiple IF Else Then
Hi All, I have two calculated Columns which I created in the Data view from other Columns. The Calculated Columns are [Number of Days] and [Action] Number of Days Action Result 4 2 Gre...
- 8 years ago
The DAX is like
Column = SWITCH ( TRUE (), yourTable[Number of Days] < 5 && yourTable[Action] <= 2, "Green", yourTable[Number of Days] < 8 && yourTable[Action] <= 2, "Yellow", yourTable[Number of Days] >= 8 && yourTable[Action] <= 2, "Red", yourTable[Number of Days] <= 15 && yourTable[Action] <= 3, "blue", yourTable[Number of Days] >= 15 && yourTable[Action] > 3, "Orange", "Violet" )
srinivt
8 years agoMicrosoft Employee
You can use IF and SWITCH function in DAX to do this. You can either use nested IFs (which should map pretty easily for your sample condition) or SWITCH with first parameter as TRUE and each condition representing an arbitrary condition expression.
drrai66
8 years agoResolver I
Hi SRINIVT,
I am Totally new to Power BI and I am stuck on this. Can you please do one more favour and write the Formula. I had tried earlier but could not do, so I posted here.
Thanks
Deepak
- Eric_Zhang8 years agoMicrosoft Employee
The DAX is like
Column = SWITCH ( TRUE (), yourTable[Number of Days] < 5 && yourTable[Action] <= 2, "Green", yourTable[Number of Days] < 8 && yourTable[Action] <= 2, "Yellow", yourTable[Number of Days] >= 8 && yourTable[Action] <= 2, "Red", yourTable[Number of Days] <= 15 && yourTable[Action] <= 3, "blue", yourTable[Number of Days] >= 15 && yourTable[Action] > 3, "Orange", "Violet" )- drrai668 years agoResolver I
Thanks and Many Many Thanks. Learnt something new from you and Solved my Problem. I used your Formula at Many many places in my dataset and it works like Charm!!!
Thanks
Deepak
- Eric_Zhang8 years agoMicrosoft Employee
Glad to help. :)
- Hema_Gupta2 years agoFrequent Visitor
Hi,
Hope this helps.
- Anuja_Chaudhari2 years agoHelper I