Stop 04 · Power Query TransformationsTopics · 11/11

Conditional and Custom Columns

Part of the Power BI Roadmap

In short

Business rules like 'orders above ₹5,000 are Large' or 'profit is amount minus cost' often need a new column. Power Query gives you a friendly dialog for simple rules and a formula box for everything else.

Conditional columns create values from if-then rules through a dialog, and custom columns let you write an M formula for anything more complex.

The jaadu weighs parcels on a big scale and pushes each one down one of three chutes marked with different coloured arrows.

Think of it like this

The sorting signboard at a parcel hub

At a parcel hub, a signboard says: heavier than 10 kg goes to bay A, heavier than 2 kg to bay B, everything else to bay C. A worker reads each parcel and follows the board. A conditional column is that signboard. A custom column is when you write your own, more detailed instructions.

Watch it happen

Order Size from Amount

750
0
12000
1
3400
2
5000
3
980
4

1/5Five order amounts in rupees.

The big ideas

What you need to know

Rules run top to bottom

The first true rule wins. Put the strictest condition first.

Custom columns use M

Write formulas like [Quantity] * [UnitPrice] or Text.Upper([City]) in Add Column, Custom Column.

Set the type

New columns default to type any. Set a type straight away or the model may treat numbers as text.

Column From Examples

Type a few desired outputs and Power Query guesses the formula. Always check what it wrote.

See it in code

Walk through the code

m
1let2    Source = Orders,3    WithSize = Table.AddColumn(4        Source,5        "Order Size",6        each if [Amount] >= 5000 then "Large"7             else if [Amount] >= 1000 then "Medium"8             else "Small",9        type text10    ),11    WithProfit = Table.AddColumn(12        WithSize,13        "Profit",14        each [Quantity] * ([UnitPrice] - [UnitCost]),15        Currency.Type16    ),17    WithFY = Table.AddColumn(18        WithProfit,19        "Financial Year",20        each if Date.Month([OrderDate]) >= 421             then "FY" & Text.From(Date.Year([OrderDate]) + 1)22             else "FY" & Text.From(Date.Year([OrderDate])),23        type text24    )25in26    WithFY

1/3The if ... else if ... else chain is exactly what the Conditional Column dialog writes.

A conditional size band, a custom profit column and an Indian financial year label (April to March).

Save yourself the pain

Common mistakes

Oops

Writing the Medium rule (>= 1000) before the Large rule (>= 5000).

Do this instead

Order rules from strictest to loosest. Otherwise every large order is caught by the Medium rule first.

Oops

Leaving the new column as type any.

Do this instead

Pass a type in Table.AddColumn or set it right after, so sums and sorting work properly.

Your mission

Add business rules

~25 min

Quick check

Using the FY rule above, which financial year does an order on 15 February 2026 belong to?

Go deeper

  1. 1Create an Age Group column with a conditional column.
  2. 2Write a custom column that calculates a discount amount.
  3. 3Decide whether the logic belongs here or in a DAX measure.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge