Forum Discussion
drrai66
Resolver I
8 years agoCalculated 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
Microsoft Employee
8 years agoYou 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
Resolver I
8 years agoHi 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 ago
Microsoft 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 ago
Resolver 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 ago
Microsoft Employee
Glad to help. :)
- Hema_Gupta2 years agoFrequent Visitor
Hi,
Hope this helps.
- Anuja_Chaudhari2 years ago
Helper I