DAX Variables in PowerBI-Subtracting Prior Value from Current Value of a Column

DAX-VARIABLES-POWERBI (2)

Table of Contents

DAX Variables in PowerBI-Subtracting Prior Value from Current Value of a Column

DAX Variables in PowerBI-Subtracting Prior Value from Current Value of a Column



My Friend got a Scenario where he was asked to subtract the prior value from the current value of the column. I helped him by finding the Solution on the Microsoft community I did not find the correct solution on it.


I have prepared the demo for describing the solution for the problem “Subtracting Prior Value from Current Value of a Column in Power BI “

So Let`s Start!!!




Step 1: I have created a dummy table “YearRevenue Table” with columns Revenue and Years.



Step 2: Now Create a Measure in the same table and place the DAX code mention below:

Diff = VAR Currentyear= MAX(‘YearRevenue Table'[Years])
VAR PreviousYears=MAX(‘YearRevenue Table'[Years])-1
VAR CurrentValue=CALCULATE(SUM(‘YearRevenue Table'[Revenue]),’YearRevenue Table'[Years]=Currentyear)
VAR PREVIOUSVALUE=CALCULATE(SUM(‘YearRevenue Table'[Revenue]),’YearRevenue Table'[Years]=PreviousYears)
VAR result= CurrentValue-PREVIOUSVALUE
return result



Step 3: After creating a Diff measure using the dax code, Place all the columns in the table
in Power View.

I hope the solution will help the developer to implement it in their report.

Categories
quick-report
Power BI Desktop
Kaushlendra Mishra

How to create a report quickly in Power BI Service?

Do you want to create a quick report in Power BI? The latest Power BI version has made it possible to create a quick report using data from the web and existing published datasets in Power BI Service. So, now you do need to download the Power BI Desktop software into your PC and directly make a report using the Power BI service.

Read More »
WHAT IS AVAILABILITY SET & AVAILABILITY ZONE
Azure
Kaushlendra Mishra

What is Availability Set and Availability Zone in Azure?

What is Availability Set and Availability Zone in Azure? In Availability Set, VM`s copy is created and is isolated with separate physical servers, computer racks, storage units, network switches in a data center within a region so if one of the VM stops working then still we have the copy of the VM working within the same datacenter. While Availability Zone ensures that complete datacenter data is replicated to another place at a distance within the same region so that even if complete data center fails due to any reason then also Availability of data is ensured.

Read More »
prepare-DP-200-exam
Azure
Kaushlendra Mishra

How to Prepare for DP-200 Exam?

I have passed the DP-200 exam on 28 Oct 2020. I have gone through the various study material and courses in order to prepare for the exam. Overall, the time taken by me for the DP-200 exam is approx 3 months. Ideally, you should not take 3 months of time but due to lack of guidance, I happen to take a number of online courses which was not required to be taken for passing the DP-200 Exam.

Read More »

Leave a Comment

Your email address will not be published. Required fields are marked *