Forum Discussion

Casey's avatar
Casey
Regular Visitor
3 years ago
Solved

Sameperiod last year

Hi, 

 

I am new to Power Bi. 

I have uploaded a Spreadsheet with the following Columns

 

Day - Month - Year - Revenue per day - Customer

 

I have created a Slicer to switch between Customers and the table is showing the following data

Rows show the Years and columns the month with the Sum of Revenue

 

Under the total coloum I need to show the difference same period last year in a %. I have looked at so many Videos and tried different Measure but not on is  providing me the outcome I require. Help is much appreciated

 

 

 

Thank you in advance 

 

Casey 

 

  • Hi Casey,

     

    There was just a small error with the DAX formula and I was able to fix it.

    Also if you want the difference to calculate for the whole year you will need a separate date table with the complete months for 2023. I added it and added a new "Total Diff Full Year" measure to calculate for all of 2023.
    Let me know if you have any further questions.

     

    Link: Items Fixed.pbix

     

    Did I answer your question? Mark my post as a solution!

5 Replies

  • Casey's avatar
    Casey
    Regular Visitor

    Hi Alan, 

    Thank you for your reply, unfortunately, it did not work. I got The end of the input was reached message. I checked everything. 

     

    Thank you 

  • Hi Casy,

     

    This isn't as straightforward as you would expect and requires the use of the ISNCOPE() function to recognize when you are not looking at the total.
    You need to build a function that captures the SUM you required for the Current year (MAX) and the previous year (MIN) and then tell the measure to calculate the difference except when it is in the Year column hierarchy (row in the matrix). Note, that this will work if you only have 2 years in the matrix. if you add more it will calculate the difference between the last and earliest years.

    You can see it applied in the bellow screen shot.

    Link to the file I built: North Wind Base - Sameperiod last year.pbix

     

     

    Did I answer your question? Mark my post as a solution!

  • Hi Casey,

     

    Can you send me an example file with your data?
    I could replicate it there and send it back.

    Upload the file to google docs or onedrive and send me the link.

     

    Regards,

    Alan

    • Casey's avatar
      Casey
      Regular Visitor

      Hi Alan, 

       

      please see below. 

       Example  

       

      Thank you again 

       

       Casey 

  • Hi Casey,

     

    There was just a small error with the DAX formula and I was able to fix it.

    Also if you want the difference to calculate for the whole year you will need a separate date table with the complete months for 2023. I added it and added a new "Total Diff Full Year" measure to calculate for all of 2023.
    Let me know if you have any further questions.

     

    Link: Items Fixed.pbix

     

    Did I answer your question? Mark my post as a solution!