Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dynamic Year Over Year comparison

Hello, with the help of a Youtube video I created a Year over Year comparison dashboard. 

So when I choose 2022, it is analyzed vs 2021. And If I choose 2021, it is compared to 2020.

 

The problem is that I would like to choose the two years to be compared. So I can compare 2022 vs other years, not only 2021.

Even if possible, compare "april 2022 vs december 2020" just so mention an example

 

Right now what I have is: 

- Calendar table from 2017 to 2022. 

- "PY MEASURE": SALES PY = CALCULATE(SUM[SALES],SAMEPERIODLASTYEAR(Calendar[date]))

- YoY Measure: 

Sales vs LY= (SUM([SALES]])-[SALES PY])/1000
 
How can I adapt this so I can chose the years to be compared?
I guess I need to change de PY Measure but I don't know how... 
 
Thank you!
  • Hi, Anonymous 

    You may need to create two separate calendar tables and then create the following measures for comparison.

    _Sales1 = calculate(SUM('Table'[Sales]),FILTER('Table','Table'[Date] in VALUES(Calendar1[Date])))
    _Sales2 = calculate(SUM('Table'[Sales]),FILTER('Table','Table'[Date] in VALUES(Calendar2[Date])))
    Sales1 vs Sales12= ([_Sales1]-[_Sales2])/1000

    Best Regards,
    Community Support Team _ Eason

2 Replies

  • v-easonf-msft's avatar
    v-easonf-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous 

    You may need to create two separate calendar tables and then create the following measures for comparison.

    _Sales1 = calculate(SUM('Table'[Sales]),FILTER('Table','Table'[Date] in VALUES(Calendar1[Date])))
    _Sales2 = calculate(SUM('Table'[Sales]),FILTER('Table','Table'[Date] in VALUES(Calendar2[Date])))
    Sales1 vs Sales12= ([_Sales1]-[_Sales2])/1000

    Best Regards,
    Community Support Team _ Eason

  • Anonymous's avatar
    Anonymous
    Not applicable

    ¡Hi! Thank you for the quick response

     

    At first I couldn't do it. He made the formulas but he couldn't get the charts. Then I noticed that I linked both calendars and you didn't and it worked!

    I have a lot of details to adjust on my dashboard but I'm definitely close
    THANKS A LOT!