Conditional column in Power Query and in Power Pivot queries
This is about conditions in queries. It is demonstrated in Power BI, but it works very similarly in Power Query.
Conditional column can be used to create a new column based on values in other columns, quite similarly to nested IF functions in Excel formula.
Lets work with this table. We´d like to create a new column, based on Weekday column. There will be "Weekend" for "Sunday" and "Saturday" and "Workday" for anything else.
Insert conditional column and define condition(s).
This is result:
You should know that:
- Queries (and M language generally) are case sensitive. This means "Sunday" is not the same as "sunday". This is very different from Excel formulas or DAX.
- Conditions are evaluated from top to bottom. Value from first TRUE condition is provided. If no condition is TRUE, then the "otherwise" value is provided.
- Values can be compared not only with text strings, but also with values from other column.
- Similarly you can use parameters.