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
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
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.

Top Solution Authors