Add Conditional Column in Power BI

Power BI Conditional column generates a new column based on the condition that we specify — for example, creating an appraisal column based on employee performance, etc. Let me show you how to add a Conditional Column in Power BI with example.

How to add Conditional Column in Power BI

To demonstrate this Power BI Conditional Column, we are going to use the SQL table that we imported in Enter Data article.

To add a conditional column, please click the Edit Queries option under the Home tab.

Add Conditional Column in Power BI 1

Clicking the Edit Queries option opens a new window called Power BI Power Query Editor. In this example, we are going to use the Sales column.

Add Conditional Column in Power BI 2

First, go to Add Column Tab. Under this tab, you can see the Conditional Column button. You can use this button to add the conditional column to this table.

Add Conditional Column in Power BI 3

Clicking the Power BI Conditional Column button opens the following window.

Add Conditional Column in Power BI 4

We changed the Column name as Rating. Next, we selected the Column name as Sales

Add Conditional Column in Power BI 5

Next, we selected the Operator as greater than, and value as 3000. Within the Values or Output text box, either you can give the static values, or you can select the column.

Add Conditional Column in Power BI 6

We added the first Rule – If Sales is greater than 3000, then return Excellent inside the rating Column. Next, click the Add rule button to add a new rule.

Add Conditional Column in Power BI 7

As you can see from the screenshot below, we added two more rules. Remember, this is the same as the Else If Statement in SQL.

Add Conditional Column in Power BI 8

You can use the ….. button to move selected Rule to up and down, or you can delete it as well. For now, we are leaving as it is, and click the OK button

Add Conditional Column in Power BI 9

From the screenshot below, you can see the new column with the information that we specified in the conditional column. Next, hit the Close & Apply option under the Home tab to apply these changes.

Add Conditional Column in Power BI 10

Now you can see the new Power BI Conditional Column called rating under the SQL Employees table.

Add Conditional Column in Power BI 11