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/
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
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.
- osinquinvdm9 years agoAdvocate II
I looked back at that page today and I just see perferct numbers
I swear I did not even do a refresh or reload or whatever of that nature (at least that I am aware of).
I'm actually glad I have a screenshot of the weird Created request count to prove I'm not crazy and that I did get those numbers yesterday.
I'm just glad it works today and will put that one on IT witchcraft.
Thanks MalS for the follow-up anyway
- osinquinvdm9 years agoAdvocate II
It is happening again !
I have been banging my head on the wall all day!
When only the Created request is present the date get associated with the creation date
But as soon I put on the grid a measure, which calculation goes through the close date, then the Created request measure "forgets" it is supposed to go through the creation date and instead sees the date as the close date, getting the data for all the creation dates associated with the current close date, thus bumping up the numbers significantly.
This is driving me nuts. Especially considering that it miraculously worked at some point