Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors