Using variables while creating custom columns in Power Query

  • Published
  • Posted in Power BI
  • Updated
  • 1 min read
  • Tagged as

Problem Statement: How to create or use variables while creating custom columns in Power Query

Solution:

To declare variables in power query, let and in keywords are used.

Scenario 1: In the below example, in a calculated column simple calculation is performed where the addition of three numbers is shown using variables.

M code is as follows:

Scenario 2: In the below example, in the Sales table there are two columns which are Unit Price and Quantity. In a single calculated column, sales value is calculated and whether the sale is above 2000 or below is mentioned using variables.

M code is as follows:

Conclusion: Multiple variables can be created in Power Query for computing different calculations.

Addend Analytics is a Microsoft Gold Partner based in Mumbai, India, and a branch office in the U.S.

Addend has successfully implemented 100+ Microsoft Power BI and Business Central projects for 100+ clients across sectors like Financial Services, Banking, Insurance, Retail, Sales, Manufacturing, Real estate, Logistics, and Healthcare in countries like the US, Europe, Switzerland, and Australia.

Get a free consultation now by emailing us or contacting us.