Forum Discussion
IF statment doesn't work!
- 9 years ago
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.)
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!
- Beyondforce9 years agoHelper I
Thanks Anonymous.
I have just started working and playing with Power BI and I still need to learn the differnces between M language and DAX, and when to use what!
I will try your idea as well as soon as I figure out where to put the code ;)
- Beyondforce9 years agoHelper I
Anonymous, Maybe you can help me with something else!
The table that I'm working on, comes from a CSV dump file (from a Main Frame). The log file doesn't count weekends, because nothing happends on weekends. But I want to add them anyway Automaticaly!
Which means, I'm going to have empty rows on the weekends rows, which is ok. Is it possible to do or would I have to create a new table for that (I hope not!)?
Thanks.
- Anonymous9 years agoNot applicable
Beyondforce If you want to display all days, you should build a date table. Then depending on what measure or calculation you use I believe you throw a "+0" at the end of your calculation to return 0 instead of "Blank"
Here is a dynamic date table that you can build in the model part in DAX. The 'FactTable' is where your dates are currently through today.
Date = ADDCOLUMNS ( CALENDAR (MINX('FactTable', [Created Date]), NOW()), "DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ), "Year", YEAR ( [Date] ), "Monthnumber", FORMAT ( [Date], "MM" ), "YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ), "YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ), "MonthNameShort", FORMAT ( [Date], "mmm" ), "MonthNameLong", FORMAT ( [Date], "mmmm" ), "DayOfWeekNumber", WEEKDAY ( [Date] ), "DayOfWeek", FORMAT ( [Date], "dddd" ), "DayOfWeekShort", FORMAT ( [Date], "ddd" ), "Quarter", "Q" & FORMAT ( [Date], "Q" ), "YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ) )