Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Dynamic YOY based on slicer selections

Hi, 

 

I've searched up and down for this and cannot seem to find any answer. 

 

I have a slicer in which I can choose two years, and based on those two years I want to see the YOxY % change. 

For example, if I choose 2023 and 2019 in the slicer, I want the measure to be able to calculate (latest date/earliest date)-1: 

 valueYOxY% Change
20191 
20232=(2/1)-1

 

thanks!

  • Hi,
     
    Below DAX Measure to achieve the above result.
     
    YOY% CHANGE =
    VAR Latest_Date_Sales = CALCULATE(SUM(Orders[Sales]),YEAR(Orders[Order Date]) = MAX(Orders[Order Date].[YEAR]))
    VAR Earlier_Date_Sales = CALCULATE(SUM(Orders[Sales]),YEAR(Orders[Order Date]) = MIN(Orders[Order Date].[YEAR]))
    VAR FINAL = ((Latest_Date_Sales/Earlier_Date_Sales)-1)
    RETURN FINAL

1 Reply

  • Subash_Govind's avatar
    Subash_Govind
    Frequent Visitor
    Hi,
     
    Below DAX Measure to achieve the above result.
     
    YOY% CHANGE =
    VAR Latest_Date_Sales = CALCULATE(SUM(Orders[Sales]),YEAR(Orders[Order Date]) = MAX(Orders[Order Date].[YEAR]))
    VAR Earlier_Date_Sales = CALCULATE(SUM(Orders[Sales]),YEAR(Orders[Order Date]) = MIN(Orders[Order Date].[YEAR]))
    VAR FINAL = ((Latest_Date_Sales/Earlier_Date_Sales)-1)
    RETURN FINAL