Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

How to Add a Conditional Column in Power Query in Excel?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

We may use Power Query to generate new columns whose values depend on one or more criteria that have been applied to existing columns in your database. The condition imposed on an existing column in the data model serves as the foundation for Power BI’s conditional column. On the Add column tab, in the General category, is the Conditional column command. In this article, we are going to discuss the Conditional column in Power Query and in Power Pivot queries.

Step By Step Implementation

Step 1: Create an excel table with fields Roll No., Student name, and Marks.

creating-excel-table

 

Step 2: Select a table. Then navigate to the data tab on the top of the ribbon and select the Get Data option and then go to from other sources and choose from Table/range.

selecting-other-sources

 

Step 3: Then create a Table dialog box appear. Here select the range and check my table has headers then click on OK.

create-table-dialog-box

 

Step 4: Now as you can see the excel table is converted to a power query editor.

table-converted-into-power-query-editor

 

Step 5: Now in the power query go to the add column tab on the top of the ribbon and here select the conditional column.

selecting-conditional-column

 

Step 6: Add Conditional Column dialog box appears. Here write the new column name and then apply the if condition.

adding-conditional-column

 

Step 7: Here in the New column name we gave a column name Pass/Fail. Then in the If condition in column name selects Marks, in Operator Select is greater than, in value write 40 and in the output write Pass. Now click on Add clause.

filling-details

 

Step 8: Now in the Else If condition in column name selects Marks, in Operator Select is less than, in value write 40 and in the output write Fail and then click OK.

else-if-condition

 

Step 9: Now as you can see new column is created with Pass/Fail name. Here it shows the students whose marks are less than 40 fail and the students whose marks are more than 40 Pass.

marks-shown

 

My Personal Notes arrow_drop_up
Last Updated : 31 Jan, 2023
Like Article
Save Article
Similar Reads
Related Tutorials