Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
kagy100
Advocate II
Advocate II

DAX Assistance Needed

Hi Team,

Here is the data table:

ID             Usage       Year        Difference       Trend

52503       0               2019       

52503       2.35          2020        2.35                Increase

52503       4               2021        1.85                Increase
Appreciate your time. 
I am trying to obtain the Difference Column via DAX formula.

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @kagy100 ,

 

You could create a index column for Financial Year. Here I used RANKX() function to get the column.

index = RANKX('Table','Table'[Year],,ASC,Dense)

7.PNG

Then use EARILER() function as below.

 

Column = 'Table'[Usage]-CALCULATE(SUM('Table'[Usage]),FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[index]=EARLIER('Table'[index])-1))

8.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

5 REPLIES 5
v-jayw-msft
Community Support
Community Support

Hi @kagy100 ,

 

You could create a index column for Financial Year. Here I used RANKX() function to get the column.

index = RANKX('Table','Table'[Year],,ASC,Dense)

7.PNG

Then use EARILER() function as below.

 

Column = 'Table'[Usage]-CALCULATE(SUM('Table'[Usage]),FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[index]=EARLIER('Table'[index])-1))

8.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

Thank you for the kind assistance.

amitchandak
Super User
Super User

@kagy100 , Create a separate year table and with help from that, have measures like

 

 

This Year = CALCULATE(sum('Table'[Usage]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Usage]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank You Amit. Any tips on how to handle if the year is a Financial Year . . .

For example, 2017-2018, 2018-2019, 2019-2020

Hi, 

It should work as well, since the max will select the last in alphabetical order, and min the first.

You might have to use VALUE funtion (convert text to number) for calculation.

Test and let us know...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.