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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Claudine_Ma
Frequent Visitor

Total YTD with USERELATIONSHIP

Hey all, 

 

I struggle with some DAX and would appreciate a little help as I can´t seem to figure this one out. 

 

So I have a client table (Dimension Table) where some clients have terminated their contracts on a certain date : 

ClientTerminationTermination Date
Client AYes15.6.2023
Client BNo 
Client CYes15.6.2024

 

This table has an inactive relationship to my Dim_Date Table 

 

Then I have a fact table with revenues like this : 

ClientBooking DateRevenue
Client B15.1.2024100€
Client C15.1.20241000€
.....  

 

This table has an active relationsjip to my Dim_Date Table (Booking Date > Date) 

 

In my overall reporting page I have some Revenue YTD Measure working well : Revenue YTD = TOTALYTD(SUM(Revenue),Dim_Date[Date])

 

Now I have been asked to add a page about the revenue loss due to termination. Therefore I would like to calcultate the Revenue YTD only for terminated clients. At the top I have a date slicer (Between). 

How can I write a DAX measure where the date slice affects both the revenue YTD (revenue only for the selected timeframe) and the termination date (only clients terminated in the selected time range)? 

 

When doing the following measure all revenues are counted unrelated to the selected timeframe : 

CALCULATE([Revenue YTD], dim_clients[Termination]="Yes", USERELATIONSHIP(dim_Date[Date], dim_clients[Terminate Date]))
I have tried a few other things but nothing seems to work so I will spare you those. 
 
Thanks for you help
Claudine 
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

How can I write a DAX measure where the date slice affects both the revenue YTD (revenue only for the selected timeframe) and the termination date (only clients terminated in the selected time range)? 

No need for the inactive relationship.   Add a filter to your calculation

 

Revenue YTD = CALCULATE(TOTALYTD(SUM(Revenue),Dim_Date[Date]),Client[Termination Date] in VALUES(Dim_Date[Date]))

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

How can I write a DAX measure where the date slice affects both the revenue YTD (revenue only for the selected timeframe) and the termination date (only clients terminated in the selected time range)? 

No need for the inactive relationship.   Add a filter to your calculation

 

Revenue YTD = CALCULATE(TOTALYTD(SUM(Revenue),Dim_Date[Date]),Client[Termination Date] in VALUES(Dim_Date[Date]))

Thanks so much. This works ! 😊

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors