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
javirmerino
Helper III
Helper III

TOTALYTD not working when using USERELATIONSHIP

Hi everyone, i'm trying to calculate a running total count of completed incidents for the year, based on the CompletionDate. However, the primary relationship between my date dimensions table and the incidents table is based on the RequestDate. The result is my figures are slightly incorrect as i'm calculating the number of completed requests raised in 2020 rather than the number of completed requests in 2020. Subtle but the discrepency is large enough to affect my analysis.

 

i know you're able to use the USERELATIONSHIP to declare a secondary link but when i try this with TOTALYTD i'm advised that this can only be used in the CALCULATE function.

 

How can i combine the CALCULATE, USERELATIONSHIP and TOTALYTD functions together to get the cumulative sum over time?


Thanks in advance for any solutions and my apologies if its been answered already. I did have a bit of a search but couldnt find a solution.

 

A

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

Hi @javirmerino

 

how have you tried to incorporate USERELATIONSHIP?

I just tried this:

ytd = TOTALYTD(sum('Table'[sales]);dates[Date];USERELATIONSHIP('Table'[date2];dates[Date]))

and it works as it should

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

View solution in original post

2 REPLIES 2
sturlaws
Resident Rockstar
Resident Rockstar

Hi @javirmerino

 

how have you tried to incorporate USERELATIONSHIP?

I just tried this:

ytd = TOTALYTD(sum('Table'[sales]);dates[Date];USERELATIONSHIP('Table'[date2];dates[Date]))

and it works as it should

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

Thanks for your response, @sturlaws . This resolved my issue.

 

I feel stupid but i'll admit the issue wasnt in my DAX - i'd created an invalid relationship between two similarly named fields. Schoolboy error!

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