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! Learn more

Reply
Sohan
Helper III
Helper III

USERELATIONSHIP not working?

I have the following relationships in my data model:

Sohan_0-1669123752242.png

 

There is an active relationship between DimCalendar[Datum] and FactAppointment[Datum afspraak]. There is an inactive relationship between DimCalendar[Datum] and FactAppointment[Boeking afspraak]. 

 

When using the following DAX I get the wrong results: 

NP = 

var numberOfNewPatients = 
CALCULATE(DISTINCTCOUNT(FactAppointment[PatientID]),
FILTER(FactAppointment, FactAppointment[EarliestDateBoeking] = TRUE() && FactAppointment[EarliestDateAfspraak] = TRUE()))

var finalMeasure = 
CALCULATE(numberOfNewPatients, USERELATIONSHIP(FactAppointment[Datum boeking], DimCalendar[Datum]))

RETURN finalMeasure

 
When I manually deactivate the relationship between DimCalendar[Datum] and FactAppointment[Datum afspraak] and activate the relationship between DimCalendar[Datum] and FactAppointment[Boeking afspraak] I get the correct result. 

 

Does Anyone know what I might be doing wrong?

8 REPLIES 8
Anonymous
Not applicable

Hi @Sohan ,

 

Has the problem be solved?

Please consider to mark the reply as solution if it's helpful.

 

FreemanZ
Super User
Super User

Be careful when using VAR. DAX Variable is actually a constant value: once defined, it never changes. So in your case, the filter argument with USERELATIONSHIP is actually useless.  Following your thread of thought, you can try to create a intermediate measure and it shall work.

Tried an intermediate measure, but get the same result.

try to add a physical column.

a imtermediate measure is not working in your case, because

a measure is implicitely wrapped with CALCULATE. So it is like this

CALCULATE(

    CALCULATE,

    USERELATIONSHIP()

)

 

As the filter argument of the inner CALCULATE has higher priority over its outer filter context (from USERELATIONSHIP), so again USERELATIONSHIP is useless.

 

@FreemanZ 
i Using USERELATIONSHIP in variables its working fine
Thanks,
Thennarasu

Thennarasu_R
Responsive Resident
Responsive Resident

CALCULATE(numberOfNewPatients, USERELATIONSHIP(DimCalendar[Datum]),FactAppointment[Datum boeking]))

@Sohan 
Change like this Now It will Work,
Thanks,
Thennarasu

Does not work unfortunately.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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