cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tvadoc
Frequent Visitor

Total Sales comparison to 2 selected Years

Hi,

I'm having troubles creating the function I mentioned in the topic.

 

1. I created a new table, Date_Previous = 'Date', so I got a copy of my original Date.

2. I chose Model View, and I created a 1-to-1 inactive relationship between Date(Date) and Date_Previous(Date) - Cross Filter direction: Both, otherwise it won't let me create it:

tvadoc_2-1665133490981.png

 

3. I created a new measure for Total Sales, previous period:

Total Sales, previous period = CALCULATE([Total Sales],REMOVEFILTERS('Date'[Year]),USERELATIONSHIP(Date_Previous[Date],'Date'[Date]))
After addig slicers from both the Date field's Year column and Date_Previous field's Year column, I get this result:
tvadoc_0-1665133198136.png

I tried to replace REMOVEFILTERS('Date'[Year]) with  REMOVEFILTERS('Date'[Date]), but I didn't quite get the desired result as well:

 

tvadoc_1-1665133233699.png
Could you please help me with this issue?
2 REPLIES 2
johnt75
Super User
Super User

Not sure you need the additional table. You could just use

Sales prev year =
CALCULATE ( [Total sales], PREVIOUSYEAR ( 'Date'[Date] ) )

Unfortunately, it is specifically requested to use the USERELATIONSHIP and the REMOVEFILTERS functions, that's why I'm trying to make this work this way.

Helpful resources

Announcements
Winner of T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Find out who won the T-Shirt Design Challenge and the top 3 finalists.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.