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:

  1. 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.
  2. 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.
  3. Values can be compared not only with text strings, but also with values from other column.
  4. Similarly you can use parameters.

Leave a Reply

Your email address will not be published.

*

clear formPost comment