Forum Discussion
IF statment doesn't work!
- 9 years ago
Beyondforce Are you creating a Calculated column?
I have 2 columns with 1 and 0. In the new column I want to create 4 option:
LateStart LateEnd Status
0 0 0
1 0 1
0 1 2
1 1 3
I need to use the IF and AND statment to create the result in the "Status" column. Later I'll use a color condition for all the 4 number options in the Status column.
- Vvelarde9 years agoCommunity Champion
- Beyondforce9 years agoHelper I
In here:
- Vvelarde9 years agoCommunity Champion
- Anonymous9 years agoNot applicable
Status = IF(AND('Table1'[LateStart] = 0, 'Table1'[LateEnd]= 0), 0, IF(AND('Table1'[LateStart] = 1, 'Table1'[LateEnd]= 0), 1, IF(AND('Table1'[LateStart] = 0, 'Table1'[LateEnd]= 1), 2, IF(AND('Table1'[LateStart] = 1, 'Table1'[LateEnd]= 1), 3, 99) ) ))You can use the above if you are in the model using DAX. (Noted after seeing VV posted.)
- Beyondforce9 years agoHelper I
Anonymous, I have tried you script, but it still doesn't work!
Vvelarde I have tried your script and it's working :)
Thank you both for your time and help.
Cheers.
- Anonymous9 years agoNot applicable
Beyondforce There are two parts to the Power BI Desktop. The screenshot you posted shows that you are in "Edit Queries" - this utilizes the "M" language - and that solution was provided by Vvelarde because he was smart enough to ask where you were trying this :) Once you "Close & Apply" then you are loading the data into the Tabular model front end. From here on out you need to use the "DAX" language when building measures or calculated columns. My solution works as a calculated column in DAX.
As you move back and forth between each area, just keep in mind the language changes.
Hope this helps out as you move forward!