Forum Discussion
Working with 2 time dimensions
- 9 years ago
You can use the USERELATIONSHIP function when you need to use the inactive relationship in your measures.
Here's a good explanation: https://www.sqlbi.com/articles/userelationship-in-calculated-columns/
You can use the USERELATIONSHIP function when you need to use the inactive relationship in your measures.
Here's a good explanation: https://www.sqlbi.com/articles/userelationship-in-calculated-columns/
- Sean9 years agoCommunity Champion
The text of the above link is correct but I think the link itself contains a few extra characters causing it to give a 404 error
Try this instead
https://www.sqlbi.com/articles/userelationship-in-calculated-columns/
Also take a look here
http://exceleratorbi.com.au/many-many-relationships-dax-explained/
- osinquinvdm9 years agoAdvocate II
I'm flabergasted by the simplicity (yet power) of the USERELATIONSHIP function .
This is exactly what I was looking for.
Thank you so much MalS for pointing to it
- osinquinvdm9 years agoAdvocate II
It kinda work but I can’t quite explain the behaviour
The active relationship is on the close_date, so looking at date or close date is the same thing
And when I want to count Requests by close date, I don’t need to do anything special (besides adding a special filter that is specific to my project).
Closed Request Count = CALCULATE([Request Count];FILTER('311_Details';'311_Details'[Nature]<>"Information"))
Where
Request Count = COUNT('311_Details'[DDS])
But when looking at open_date, we can see that there is no active relationship with the generic time dimension
But when adding a measure that enforces the use of the relationship, like:
Created Request Count = CALCULATE([Closed Request Count];USERELATIONSHIP('311_Details'[Open Date];AllDates[Date])).
We see that now looking at date or close date becomes the same thing
When adding all dates to the grid the data still looks like expected
Even when removing the close date
But I can’t figure out why the number explodes when we only put the generic time dimension on the grid
Ultimately what I need is to see for a given date
How many closed request we have (through the date/closed date relationship)
How many open request we have (through the date/open date relationship)
Basically what I’d like to see: is
Date | Created Request Count | Closed Request Count
1 Jan 2014 | 76 | 24
- MalS9 years agoResolver III
Those measures look pretty good to me. (I assume that '311_details'[DDS] is just the request ID field?)
I would carefully check the relationships that you have set up. If possible, while troubleshooting, remove/deactivate all relationships except the active relationship between Date and Close Date, and the inactive one between Date and Open Date.