Reply
joluwa
Helper I
Helper I
Partially syndicated - Outbound

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 ?

 

joluwa_1-1707303243560.png

 

 

1 ACCEPTED SOLUTION

Syndicated - Outbound

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

View solution in original post

4 REPLIES 4
joluwa
Helper I
Helper I

Syndicated - Outbound

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

Syndicated - Outbound

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.

danextian_0-1707393606841.png

 





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.

Syndicated - Outbound

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

danextian
Super User
Super User

Syndicated - Outbound

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.
avatar user

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 Solution Authors (Last Month)
Top Kudoed Authors (Last Month)