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.