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
Anonymous
Not applicable

Calculate Year-over-year change in another way

Dear all

 

I am trying to calcualte year-over-year change by another way (not using date table).

 

Year_Filter

Year
2017
2018
2019

 

 

Data

YearCustomerRevenue
2017A10
2017B20
2017C15
2018A5
2018B10
2019A15
2019B30
2019C10
2019D15

 

I am trying to calculate the year-over-year change rate by the measure below, but it does not work:

 

YoY_Change_ =

VAR _current_ = calculate(sum(Revenue))

VAR _last_year_ = calculate(sum(Revenue), FILTER(data, data[data] = selectedvalue(Year_Filter[Year]-1)

return

divide(_current_,_last_year)-1

 

I expect this measure will return:

 

 YoY
2017 
2018-44%
2019180%

 

Can someone kindly point out how I should write the measure? Many thanks!

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

 

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

 

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@Anonymous , try like

 

YoY_Change_ =
var _max = maxx(allselected(Year_Filter), Year_Filter[Year])
VAR _current_ = calculate(sum(Revenue))
VAR _last_year_ = calculate(_current_, FILTER(all(Year_Filter), Year_Filter[Year] = _max-1))
return
divide(_current_,_last_year)-1

Anonymous
Not applicable

@amitchandakthank you for your reply as well. Your solution works perfectly as well. Sadly I can only select one solution at this moment. Much appreciated! 

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.

Top Solution Authors