Saturday, December 9, 2017

How to Add a Conditional Column to a Table in Power BI

What is Conditional Column and How to Add it to a Table in Power BI
Conditional Column is a New Column that will be Created based on a Condition defined on an Existing Column
Scenario :

Suppose we have the Sales Table with an existing Column "Units_Sold". Based on this Column I want create a new Column as "SalesPerformanceFlag" based on the below Conditions..

If the no.of Units_Sold < 15 then SalesPerformanceFlag ='Poor'

If the no.of Units_Sold < 30 then SalesPerformanceFlag ='Good'
Else SalesPerformanceFlag ='Best'

We can fulfill this Scenario as follows...

1) Go to Home > Edit Queries

2) Next Go Query Editor > Add Column > Conditional Column

3) Define the Name and Condition for the New Conditional Column
Click on the "Add Rule" to add more Else If conditions.

Notes :
Here in the above , for Else Case(Other wise) , you can display the same/other Colum Value if required as shown below..

Once you defined the Condition, next say OK. Now a new Conditional Column will be added after the last Column of the Table.
You can change the position of the column by dragging it to desired position.

Notes :
You can Track your changes/edits that you applied on the Table from the "Applied Steps" panel of Query Settings. From here you can Revert back/Undo your changes by deleting them. Or you can modify them by Clicking on the Settings Icon. 

Next Save and Close the Query Editor window, and then Apply the Pending Changes to the Query Editor.
Finally Refresh the Report.

Output :
Now we will see the new Conditional Colum ( SalesPerformanceFlag) added to the existing Table at the Power BI Data model.

--------------------------------------------------------------------------------------------------------
Thanks, TAMATAM ; Business Intelligence & Analytics Professional
--------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.