Power BI Course
Conditional Columns
Conditional Column is the point-and-click version of a Custom Column if statement. Instead of writing M code, you fill in a dialog with dropdown menus — pick a column, pick an operator, enter a value, enter an output. For straightforward rules with a small number of branches, it is faster and less error-prone than writing M by hand. But the dialog has real limits, and knowing exactly where those limits are — and how to break through them by editing the generated M — is what this lesson is about.
The Conditional Column Dialog
Conditional Column lives on the Add Column tab. Each row in the dialog is one if/else if branch. The final row is the "else" — what to output when no condition matches. You can add as many branches as needed using the Add Clause button.
The M Code the Dialog Generates
Every Conditional Column step is stored as M code in the Applied Steps. Clicking the gear icon on the step reopens the dialog — but you can also click into the formula bar to see and edit the raw M. Knowing what the dialog generates lets you spot patterns and extend them when the UI is not enough.
// M generated by the Conditional Column dialog above
#"Added Conditional Column" = Table.AddColumn(
#"Changed Type",
"RevenueTier",
each if [Revenue] >= 1500 then "Platinum"
else if [Revenue] >= 1000 then "Gold"
else if [Revenue] >= 500 then "Silver"
else "Bronze"
)
// Note: the dialog always generates "else" at the end —
// this becomes the fallback value for any row that
// does not match any of the defined conditions.
| OrderID | Revenue | RevenueTier |
|---|---|---|
| 1001 | 1,200 | Gold |
| 1002 | 850 | Silver |
| 1003 | 430 | Bronze |
| 1004 | 95 | Bronze |
| 1005 | 1,540 | Platinum |
All Available Operators in the Dialog
| Operator (as shown in dialog) | Works on | M equivalent |
|---|---|---|
| equals | Text, Number, Date | [Col] = value |
| does not equal | Text, Number, Date | [Col] <> value |
| is greater than | Number, Date | [Col] > value |
| is greater than or equal to | Number, Date | [Col] >= value |
| is less than | Number, Date | [Col] < value |
| is less than or equal to | Number, Date | [Col] <= value |
| begins with | Text only | Text.StartsWith([Col], value) |
| ends with | Text only | Text.EndsWith([Col], value) |
| contains | Text only | Text.Contains([Col], value) |
| does not contain | Text only | not Text.Contains([Col], value) |
| is null | Any type | [Col] = null |
| is not null | Any type | [Col] <> null |
What the Dialog Cannot Do — And How to Fix It
The Conditional Column dialog is useful but deliberately limited. Six common requirements fall outside what the dialog supports — each has a workaround using the formula bar or Custom Column.
[DueDate]. The dialog cannot express this but M handles it perfectly.and / or keywords directly.[Revenue] * 0.1."Discount" to [Revenue] * 0.1.try … otherwise null for any branch that does arithmetic.Extending the Generated M in the Formula Bar
The most productive workflow is to build the basic structure in the Conditional Column dialog, click OK, then refine the generated M in the formula bar. You get the speed of the UI for the skeleton and the full power of M for the details.
// BEFORE — what the dialog generates (column comparison as literal)
each if [Revenue] >= 1000 then "High" else "Low"
// AFTER — edited in formula bar to compare two columns
each if [Revenue] >= [Target] then "On Target" else "Below Target"
// BEFORE — dialog generates a text output
each if [Status] = "Late" then "Penalty" else "None"
// AFTER — edited to calculate a numeric output
each if [Status] = "Late"
then try [Revenue] * 0.05 otherwise null // 5% late penalty
else 0
// BEFORE — dialog can only check one column per clause
each if [Revenue] >= 1000 then "Flag" else ""
// AFTER — compound condition added in formula bar
each if [Revenue] >= 1000 and [CustomerTier] = "Premium"
then "Priority Flag"
else if [Revenue] >= 1000
then "High Value"
else ""
| OrderID | Revenue | CustomerTier | Flag |
|---|---|---|---|
| 1001 | 1,200 | Premium | Priority Flag |
| 1002 | 850 | Standard | (blank) |
| 1003 | 430 | Premium | (blank) |
| 1004 | 95 | Standard | (blank) |
| 1005 | 1,540 | Premium | Priority Flag |
Conditional Column vs Custom Column — Decision Guide
| Conditional Column (dialog) | Custom Column (M code) | |
|---|---|---|
| Best for | Simple text or number categorisation — one column, fixed literal values, no arithmetic in the output | Any logic involving column-to-column comparisons, AND/OR, calculated outputs, null safety, or more than 5 branches |
| Requires M knowledge? | No — fully point-and-click | Yes — must write M syntax |
| Column vs column compare | Not directly — literal values only (workaround: edit the M after) | Yes — full M expression |
| AND / OR conditions | No — one column per clause | Yes |
| Calculated output | No — literal or column reference only | Yes — any M expression |
| Extendable after creation? | Yes — reopen dialog or edit M in formula bar | Yes — edit M directly |
Teacher's Note: The most useful workflow at an intermediate level is: use the Conditional Column dialog to scaffold the branch structure quickly, click OK, then immediately click into the formula bar and extend the M where the dialog fell short. You get the visual structure of the dialog without being trapped by its limitations. Treat the dialog as a code generator, not as the final editor.
Practice
Practice 1 of 3
In the Conditional Column dialog, each row of the grid represents one ___ / else if branch, and the final row is the "else" fallback that applies when no condition above it matches.
Practice 2 of 3
The Conditional Column dialog cannot compare two columns against each other — the Value field only accepts a typed literal. The fastest fix is to build the structure in the dialog, click OK, then edit the generated M in the ___ bar to replace the literal with the second column reference.
Practice 3 of 3
You need a column that outputs [Revenue] * 0.05 for late orders and 0 for all others. Because the output is a calculated expression rather than a fixed value, the Conditional Column dialog alone cannot do this — you must use a Custom Column or ___ the generated M in the formula bar.
Lesson Quiz
Quiz 1 of 3
You build a Conditional Column with four clauses — Platinum ≥ 1500, Gold ≥ 1000, Silver ≥ 500, Bronze for else — and reopen the dialog to add a new "Diamond ≥ 2000" tier. You add it as the fifth clause at the bottom, above the Bronze else row. What is wrong with this and how do you fix it?
Quiz 2 of 3
Which of the following scenarios is best handled by Conditional Column rather than Custom Column?
Quiz 3 of 3
You use the "contains" operator in the Conditional Column dialog to flag any Description column that contains the word "urgent". A row has Description = "URGENT delivery required". The flag does not appear for that row. What is the most likely cause?
Next up — Lesson 28 covers Date and Time Transformations in Power Query, including building a full Calendar table from scratch, extracting every date component needed for time intelligence, and the patterns that make DATEYTD and SAMEPERIODLASTYEAR work correctly in DAX.