Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Switch between active and inactive relationships in a measure - 1table&multiple relationships

Hi all,

I'd like to check if my understanding is correct, thanks for the help in advance!

I have a date and a fact table between those there are 2 relationships (both 1:N, one-directional):

 

1) Calendar[Date] --> Fact[Start_Date] (active)

2) Calendar[Date] --> Fact[End_Date] (inactive)

 

The business requirement is to calculate the number of rows by month where the item in the row is/was "active", so:

If the take 2024 Jan as an example:

All rows should be counted if:

1) Fact[Start_Date] is on or before 31 Jan 2024

2) Fact[End_Date] is on or after 31 Jan 2024 OR Fact[End_Date] is BLANK

 

A way to calculate this without relying on the relationships is:

 

v1 =

VAR Last_Date = LASTDATE ( Calendar[Date] )

VAR result = 

CALCULATE (
    COUNTROWS ( Fact ),
    REMOVEFILTERS ( Calendar), -- Remove date filers used on the dashboard
    Last_Date  >= Fact[Start_Date],
    
    Last_Date  <= Fact[End_Date]  ||
    Fact[End_Date]   = BLANK()
    
) 

return

result

 

 

If I wanted to use the relationship it can be transformed to this:

 

v2 =

VAR Last_Date = LASTDATE ( Calendar[Date] )

VAR result = 

CALCULATE (
    COUNTROWS ( Fact ),
    REMOVEFILTERS ( Calendar), -- Remove date filers used on the dashboard
    Last_Date  >= Calendar[Date], -- this acts as Start_Date
    
    Last_Date  <= Fact[End_Date]  ||
    Fact[End_Date] = BLANK()
    
) 

return

result

 

 

Is there any way to create this measure in a way that both the active and the inactive relationships are used?

To me it is a simple requirement but based on my current understanding it cannot be done in DAX. According to my current knowledge it contradicts the way CALCULATE modifyers work. As far as I understand it doesn't metter where I put USERELATIONSHIP to activate the inactive relationship it will transform all my Calendar[Date] to End_Date and I cannot write a measure where in one CALCULATE function I switch between the 2 dates. A similar measure would look like this:

 

v3 =

VAR Last_Date = LASTDATE ( Calendar[Date] )

VAR result = 

CALCULATE (
    COUNTROWS ( Fact ),
    REMOVEFILTERS ( Calendar), -- Remove date filers used on the dashboard
    Last_Date  >= Calendar[Date], -- Start_date
    
    ****[DO SOMETHING HERE to switch from Start to End Date]****
    Last_Date  <= Calendar[Date]  || -- End_Date
    Calendar[Date]   = BLANK()       -- End_Date
    
) 

return

result

 

 

So I can ever only use one of the relationships and I need to specifically reference the other columns (write Fact[End_Date] as filter argument) from fact table, even if there's an inactive, potentially usable relationship. Is this assumtipon of mine correct? 

 

Thanks,  

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Right, only one relationship can be active at a time. You could create a second Calendar table and link one to Start Date and one to End Date. I made a video on a similar problem here: 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks!

Greg_Deckler
Community Champion
Community Champion

@Anonymous Right, only one relationship can be active at a time. You could create a second Calendar table and link one to Start Date and one to End Date. I made a video on a similar problem here: 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors