Forum Discussion

HB13's avatar
HB13
Helper I
4 years ago

Tracking year by year changes

Hi all

I have a simple line graph that is looking at an average premium amount per month for the last 48 calender months (01/07/2018 - 30/06/2022)

 

 

I now need to create a second visual that tracks the year on year change in the average monthly premium. For example,
((June 2022 avg prem) / (June 2021 avg prem)) - 1

I don't know how to achieve this in a measure, hoping someone can assist.

 

Many thanks!

 

4 Replies

  • HB13 , Create a date table, Join with date of your date table, create MOM measure like the below examples and use that on secondary line axis

     

    MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
    last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
    last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

    diff = [MTD Sales]-[last MTD Sales]
    diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

     

     

    Power BI β€” Qtr on Qtr with or Without Time Intelligence
    https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839
    https://www.youtube.com/watch?v=8-TlVx7P0A0

    • HB13's avatar
      HB13
      Helper I

      Thank you for your response, much appreciated πŸ˜„
      This helps with month on month changes but I need to calculate a Year on Year change for the (last 48) months that are being filtered for

  • Hi HB13 ,

     

    Please try:

    Add a new column to calculate the changes:

    Column =
    
    var _a =CALCULATE(MAX('Table'[Value]),FILTER('Table',YEAR([Date])=YEAR(EARLIER('Table'[Date]))-1&&MONTH([Date])=MONTH(EARLIER('Table'[Date]))))
    
    return IF(ISBLANK(_a),BLANK(),CALCULATE(MAX('Table'[Value]),FILTER('Table',[Date]=EARLIER('Table'[Date])))/ _a-1)

    Then create a date table and create relationship between the two tables:

     

    Apply date and the column to the line chart:

     

    Final output:

     

    Best Regards,

    Jianbo Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Hi HB13 ,

     

    Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

    Refer to:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

     

    Best Regards,

    Jianbo Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.