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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
JRF_PowerBI
Frequent Visitor

Ignore relationship with date table while still referencing date table in measure

Bit of a weird problem that I haven't come across before that I just can;t figure out how to get around. I'm using a data model (not mine) where the Date table has a relationship with the Asset Status table on the EffectiveFromDate (in Asset Status table - see below for example of data). For this measure I'm trying to create, I want to ignore that relathionship becuase I need to include the rows in the Asset Status table where the EffectiveFromDate is not in the filtered date range. HOWEVER, I do need to reference the filtered Date table as part of the expression in my SUMX calculation. Here is the measure before I try to ignore the active relationship...it calculates fine:

 
DaysVoidinPeriod =
SUMX (
    'AssetStatus',
    VAR EffectiveFrom = 'AssetStatus'[EffectiveFromDate]
    VAR EffectiveTo =
        IF (
            ISBLANK ( 'AssetStatus'[EffectiveToDate] ),
            MAX ( Date_DIM[FullDate] ),
            'AssetStatus'[EffectiveToDate]
        )
    VAR StartDate =
        MAX ( EffectiveFrom, MIN ( Date_DIM[FullDate] ) )
    VAR EndDate =
        MIN ( EffectiveTo, MAX ( Date_DIM[FullDate] ) )
    RETURN
        IF (
            StartDate <= MAX ( Date_DIM[FullDate] ),
            DATEDIFF ( StartDate, EndDate, DAY ),
            BLANK ()
        )
)
 
Problem is, however I try to apply ALL or REMOVEFILTERS to the SUMX function, it is messing up the MAX and MIN functions that refer to the date table. Below is an example of the data in the Asset Status table. Essentially what I want the measure to be able to do is to apply the SUMX measure above, but across all rows in the Asset Status table, so it isn't filtering out rows where the EffectiveFrom date is outside the filtered range (which is what is happening currently).
JRF_PowerBI_1-1696934793478.png

 

Any help would be much appreciated!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Modify the existing relationship to be inactive.  Then, when you need it, add USERELATIONSHIP to your CALCULATE modifiers. 

View solution in original post

2 REPLIES 2
JRF_PowerBI
Frequent Visitor

Thanks! Yes this worked great - I'd got my head stuck in thinking I had to acheive this through DAX.

lbendlin
Super User
Super User

Modify the existing relationship to be inactive.  Then, when you need it, add USERELATIONSHIP to your CALCULATE modifiers. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors