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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BICrazy
Helper II
Helper II

Calculate Percentage Change from First to Last Date

Hi the Power BI Community,

I've been able to calculate the YoY percentage change, however, I need to calculate the percentage change from the earliest year (2010) to the latest year(2018) of a data set and display this as a card.

Here are my current calculations which are correct.
Data.PNG

The 7.06%  calculated below is what I'd like to show as a card visual.

StartEndDifference% Change
201020182018-2010Difference/2010
80,7486,445,77,06%

 

Thanks

3 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@BICrazy , Try measure like

 

new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = minx(allselected(Date),Date[Date])
return
calculate( sum(Table[Value Reff]), filter(allselected('Date'), 'Date'[Date]=_max)) -
calculate( sum(Table[Value Reff]), filter(allselected('Date'), 'Date'[Date]=_min))

 

 

or

 

new measure =
var _max = maxx(all(Date),Date[Date])
var _min = minx(all(Date),Date[Date])
return
calculate( sum(Table[Value Reff]), filter(all('Date'), 'Date'[Date]=_max)) -
calculate( sum(Table[Value Reff]), filter(all('Date'), 'Date'[Date]=_min))

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

All measures are in the attached pbix file.

 

Picture1.png

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

@Jihwan_Kim  Appreciate the response Jihwan.  This option would have also worked as a solution.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

All measures are in the attached pbix file.

 

Picture1.png

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@Jihwan_Kim  Appreciate the response Jihwan.  This option would have also worked as a solution.

amitchandak
Super User
Super User

@BICrazy , Try measure like

 

new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = minx(allselected(Date),Date[Date])
return
calculate( sum(Table[Value Reff]), filter(allselected('Date'), 'Date'[Date]=_max)) -
calculate( sum(Table[Value Reff]), filter(allselected('Date'), 'Date'[Date]=_min))

 

 

or

 

new measure =
var _max = maxx(all(Date),Date[Date])
var _min = minx(all(Date),Date[Date])
return
calculate( sum(Table[Value Reff]), filter(all('Date'), 'Date'[Date]=_max)) -
calculate( sum(Table[Value Reff]), filter(all('Date'), 'Date'[Date]=_min))

@amitchandak  Thanks a mill.  This solution worked like a charm.  I just hard-coded the year's as my dataset min year starts at 1960 and max year ends at 2020.

Here is the sample of my Dax:

% Change GDP per capita, PPP (current international $) = 
var _min = YEAR( " December 2010" )
var _max = YEAR( "December 2018" )
var _calc =calculate( [Private health expenditure (% of current health expenditure)], filter(ALL( Data_WB_HNP_WDI), Data_WB_HNP_WDI[Year]=_max)) -
calculate( [Private health expenditure (% of current health expenditure)], filter(ALL( Data_WB_HNP_WDI), Data_WB_HNP_WDI[Year]=_min))

return
DIVIDE( _calc, calculate( [Private health expenditure (% of current health expenditure)], filter(ALL( Data_WB_HNP_WDI), Data_WB_HNP_WDI[Year]=_min)), 0 )


Solution:
Data.PNG

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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