- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

DAX measure to do the opposite of USERELATIONSHIP
I have a DAX code called DateDiff that checks count of days between the campaign start and end date that fall within the calendar date slicer which worked fine.
However, upon doing more testing I noticed it returns an incorrect number due to the direction its travelling in based on the relationship.
DateDiff = VAR selectmin = MIN ( CalendarTable[Calendar Date]) VAR selectmax = MAX (CalendarTable[Calendar Date]) VAR firstDateSelect = IF ( selectmin <= [mincheck], [mincheck], selectmin ) VAR secondDateSelect = IF ( selectmax >= [maxcheck], [maxcheck], selectmax ) RETURN DATEDIFF ( firstDateSelect - 1, secondDateSelect, DAY )
So I need the DAX calculation to travel in the blue arrow direction, as currently when I turn the relationship from the range table and overview table to inactive, the calculation returns the correct result.
Is this possible to do in DAX to force a DAX to travel in a certain direction when both relationships are active ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I managed to sort the issue, I just turned the relationship to inactive and then used the USERELATIONSHIP function in my other DAX measures and the measure which I was originally having trouble with started working as it should
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

PBIX File: https://drive.google.com/file/d/19K7v0hoXpeNuW9ldENzK65Ht8im9OjcM/view?usp=sharing
I tried using CROSSFILTER but this still returns 104, but it should return 105
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @joluwa ,
I've been exploring your pbix but havent been able to wrap my head around what you're trying to achieve.
First, why use a separate dates table when what you're trying to return is simply the max and min dates in Overview Table? I can't find CalendarTable being used anywhere else. Using min and max on day_id would have returned the same result.
Second, based on the current slicer selections in your pbix, what values do you expect for these? Why 105 and not 104.
Dane Belarmino | Microsoft MVP | Proud to be a Super User!
Did I answer your question? Mark my post as a solution!
"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I managed to sort the issue, I just turned the relationship to inactive and then used the USERELATIONSHIP function in my other DAX measures and the measure which I was originally having trouble with started working as it should
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @joluwa ,
You have the option to utilize CROSSFILTER to adjust a relationship within the scope of a measure. If this method doesn't suit your needs, kindly provide a sample dataset that is usable (not an image) along with your anticipated outcome. You can share a link to a PBIX or Excel file with any sensitive information removed via Google Drive, OneDrive, or Dropbox.
Dane Belarmino | Microsoft MVP | Proud to be a Super User!
Did I answer your question? Mark my post as a solution!
"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
07-03-2024 06:01 AM | |||
09-25-2024 08:50 AM | |||
06-18-2024 12:55 PM | |||
06-19-2024 08:36 AM | |||
09-17-2024 10:55 AM |
User | Count |
---|---|
122 | |
105 | |
85 | |
52 | |
46 |