cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Anonymous
Not applicable

PowerBI USERELATIONSHIP function used in a measure not working with an inactive relationship

Hi All,

 

Hope everyone is doing fine. 

I am in the middle of a weird scenario and need help. Please see screenshot below that shows 3 different relationships, one active and two other as non active ones between a DATE table and PSR Data table. Obviously, due to ambiguity, I can not make all three active so the primary active one is between Planned finish from PSR Data table to Date field in Date table.

Capture.PNG

Now for the measure calculation, see the formula I am using below:

Actual RT New = 
if(
    SELECTEDVALUE('Dates'[Date]) >= [First Actual] && SELECTEDVALUE('Dates'[Date]) <= [Last Actual], 
    CALCULATE(SUM('PSR Data'[Actual Count]),USERELATIONSHIP(Dates[Date],'PSR Data'[Actual Finish]),
	    FILTER(
            ALLSELECTED('Dates'[Date]),
            ISONORAFTER('Dates'[Date], Max('Dates'[Date]), DESC) 
            ) 
        ),
	Blank()
)

 

However, using the USERELATIONSHIP function above is not giving me accurate calculation output. Is the syntax wrong?
If I take out userelationship function from the measure and use expression below for the measure:

Actual RT New = 
if(
    SELECTEDVALUE('Dates'[Date]) >= [First Actual] && SELECTEDVALUE('Dates'[Date]) <= [Last Actual], 
    CALCULATE(SUM('PSR Data'[Actual Count]),
	    FILTER(
            ALLSELECTED('Dates'[Date]),
            ISONORAFTER('Dates'[Date], Max('Dates'[Date]), DESC) 
            ) 
        ),
	Blank()
)

AND Also, I changed the primary relationship to set as below

Capture2.PNG

It then gives me accurate results so the measure does work well in that case but I have to use the combination of inactive relationship between actual finish field from psr and date from date table and leverage userelationship function in the measure, can someone please help me with correct measure syntax, thanks in advance.

 

1 ACCEPTED SOLUTION
sm_talha
Resolver II
Resolver II

In order to use USERELATIONSHIP function you must keep all the relationships 'In-Active', otherwise the existing active relationship will override the relationship you are trying to make using USERELATIONSHIP function. Try deactivating all relationships and use your first measure, it should give you expected result.

View solution in original post

2 REPLIES 2
sm_talha
Resolver II
Resolver II

In order to use USERELATIONSHIP function you must keep all the relationships 'In-Active', otherwise the existing active relationship will override the relationship you are trying to make using USERELATIONSHIP function. Try deactivating all relationships and use your first measure, it should give you expected result.

Anonymous
Not applicable

@sm_talha  thank you so much, that worked like a charm!

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors