How to create a conditional column in Power BI (Power Query)
A conditional column in Power BI lets you create a new column whose value depends on rules you define — for example, tagging each sale as "High", "Medium" or "Low" based on the amount. It is a simple way to categorize data directly in Power Query, without writing formulas, and it is ideal for anyone getting started. With a practical sales-classification example, you can do it in a few clicks and understand what Power BI generates behind the scenes.
Prerequisites
- Power BI Desktop installed (the free version is enough).
- A table already loaded with at least one numeric column — for example, a
Salescolumn. - Basic Power BI navigation skills (no DAX required).
Step 1: Open the Power Query Editor
A conditional column is created in Power Query, the editor where you prepare data before using it in visuals. On the Home tab, click Transform data to open the Power Query Editor window. On the left, in the queries list, select the table where you want to add the column. Power Query records every transformation as a step, so you can always go back if something goes wrong.
Step 2: Open the Conditional Column window
With the table selected, go to the Add Column tab and click Conditional Column. A window opens where you set the new column name and the "if… then…" rules, all visually and without writing code. Unlike a DAX calculated column, this column is created while the data loads, which usually keeps the model lighter.
Step 3: Define the rules (example)
Let's classify the Sales column into three levels. Fill in the window like this:
- New column name:
Category - If
Salesis greater than or equal to 1000, then "High". - Click Add clause and set: If
Salesis greater than or equal to 500, then "Medium". - In the Else field, type "Low".
Clause order matters: Power Query reads from top to bottom and applies the first rule that is true. So always place the most restrictive conditions (the highest value) at the top; otherwise everything would fall into the first rule. You can add as many clauses as you need to create more levels.
Tip: if you need to compare text instead of numbers, change the operator to "equals" and type the exact value to compare.
Step 4: Review the generated M code
When you click OK, Power Query automatically writes the code in the M language. You can see it in the formula bar or in the Advanced Editor, and it looks like this example:
= Table.AddColumn(Source, "Category", each
if [Sales] >= 1000 then "High"
else if [Sales] >= 500 then "Medium"
else "Low")
Understanding this code helps you tweak the rules by hand when the visual window is not enough — for example, to combine two conditions on the same line.
Step 5: Apply the changes
On the Home tab, click Close & Apply. Power BI runs the Power Query steps and loads the new Category column into the model, ready to use in visuals, slicers and measures.
Verify the result
Open the Data view (the table icon on the left) and confirm that the Category column shows "High", "Medium" or "Low" according to the Sales values. If you see an error or blank values, check that the Sales column is really a number type: a wrong data type is the most common cause of failure in a conditional column. For a quick test, drag the Category column into a table visual next to Sales and check that each amount gets the right label.
Conclusion
In just a few clicks you created a conditional column in Power BI and categorized your data without complex formulas, making the report clearer and easier to filter. The natural next step is to try rules with two conditions at once (for example, high sales only in a specific region) or move the same logic into a DAX calculated column. What will be the first category you create in your data?