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
Winz08
Regular Visitor

Displaying history for 3 previous years

Hi I am trying to accomplish something that seems basic but I cannot figured out how to do. Desperately need help!

I have an expense history that goes back 4 years. And a date table that includes month and year for all transactions. I have a slicer which selects 2018 and I am able to view my expenses in all the ways I want. I have figured out how to add a coloum to compare to the same period last year, but have not figured out how to create a coloum for each of the 2 previous years (2016 and 2015) so that I can compare data to all 3 previous years. Can anyone help?
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Winz08,

 

Not really sure about your total setup but from your setup I'm assuming you have a expense table with lines for all the dates in the 4 years and a dates table that relates to the date in the expense table.

 

In this case the better way to do the calculation is not to add a column with all the years but a measure that calculates this.

 

CY = SUM(Expenses[Expense])

previous year = CALCULATE([CY];DATEADD(Dates_Table[Date];-1;YEAR))

previous 2 year = CALCULATE([CY];DATEADD(Dates_Table[Date];-2;YEAR))

previous 3 year = CALCULATE([CY];DATEADD(Dates_Table[Date];-3;YEAR))

Then add it to your visual

 

As you can see in the PBIX attach it get values even when you select the month filter.

Regards,

MFelix

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Winz08,

 

Not really sure about your total setup but from your setup I'm assuming you have a expense table with lines for all the dates in the 4 years and a dates table that relates to the date in the expense table.

 

In this case the better way to do the calculation is not to add a column with all the years but a measure that calculates this.

 

CY = SUM(Expenses[Expense])

previous year = CALCULATE([CY];DATEADD(Dates_Table[Date];-1;YEAR))

previous 2 year = CALCULATE([CY];DATEADD(Dates_Table[Date];-2;YEAR))

previous 3 year = CALCULATE([CY];DATEADD(Dates_Table[Date];-3;YEAR))

Then add it to your visual

 

As you can see in the PBIX attach it get values even when you select the month filter.

Regards,

MFelix

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank you!!!

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.