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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply

Table Relationship Query USERELATIONSHIP()

Hi Community,
I am having some difficulty using USERELATIONSHIP function in Power BI and I'm hoping I can get some assistance. I have an inactive relationship between 2 tables, and I want to activate it for the calculation of a measure. I have used the attached formula, however if I simply activate the relationship, the values appearing in my visualisations are different to the values calculated by the measure. 
Shouldn't USERELATIONSHIP() behave as if the relationship were active?
Thank you. 
Inactive_relationship_needed_for_the_measure.pngTickets_resolved_measure_DAX.pngValues_when_relationship_is_made_active.pngValues_when_USERELATIONSHIP_is_used.png
[ Tickets_Resolved ] =
CALCULATE (
COUNTX( AllPPMTickets, AllPPMTickets[Ticket_id] ),
USERELATIONSHIP(AllPPMTickets[Resolved_date_time], Dates[Date] ),
FILTER( AllPPMTickets , AllPPMTickets[Resolved_status] = TRUE )

)
3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Hi, @jaime_blackwell , based on your description, I think the order of evalution in CALCULATE matters.

 

CALCULATE(<expression>[, <filter1> [, <filter2> [, …]]])

 

filters evaluate parallelly, which means, in your case, FILTER( AllPPMTickets , AllPPMTickets[Resolved_status] = TRUE ) doesn't get affected by USERELATIONSHIP(AllPPMTickets[Resolved_date_time], Dates[Date] ); it evaluates under the former active relationship.

You may try this measure,

 

[ Tickets_Resolved ] =
CALCULATE (
    COUNTX ( AllPPMTickets, AllPPMTickets[Ticket_id] ),
    CALCULATETABLE (
        FILTER ( AllPPMTickets, AllPPMTickets[Resolved_status] = TRUE ),
        USERELATIONSHIP ( AllPPMTickets[Resolved_date_time], Dates[Date] )
    )
)

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Hi @CNENFRNL ,

Thanks so much for that suggestion, however the values produced by the measure you provided are the same. I figured that the order of the filter and userelationship functions would be irrelevant because the relationship does not affect the filtered column, so the result should be the same either way. 

The measure is basically behaving as though the USERELATIONSHIP() function isn't working at all. 

Update: I was able to resolve the issue using the below

[ Tickets_Resolved ] = 
   
 VAR 
    PPMTickets = CALCULATETABLE (
                FILTER ( AllPPMTickets, AllPPMTickets[Resolved_status] = TRUE ),
                USERELATIONSHIP ( AllPPMTickets[Resolved_date_time], Dates[Date] )
            )
            
RETURN
    COUNTROWS( PPMTickets ) 

Thank you again for your help! 

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.