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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
shefali_13
Regular Visitor

USERELATIONSHIP function can only use the two columns references participating in relationship

Hi, I have inactive relationships set up between 'MyReport' and 'LegendCategories' table; however, I am still seeing the error 'USERELATIONSHIP function can only use the two columns references participating in relationship' in this code:

Varible = 
SWITCH(
TRUE(),
---------GENDER---------
SELECTEDVALUE(LegendCategories[Field]) = "Gender",
CALCULATE(
[CountPersons], #custom measure to count the number of names in a column
USERELATIONSHIP('MyReport'[Gender], LegendCategories[Category])
),
---------Race---------
SELECTEDVALUE(LegendCategories[Field]) = "Race",
CALCULATE(
[CountPersons], #custom measure to count the number of names in a column
USERELATIONSHIP('MyReport'[Race], LegendCategories[Category])
),
BLANK()
)

I rechecked the relationships, confirmed the spellings, interchanged the syntax of USERELATIONHIP such that 'many' table comes before the 'one' table (as I have 'Many to 1' relationship set here). Nothing seems to be working! Any advice? 

 

Thanks so much!

1 REPLY 1
amitchandak
Super User
Super User

@shefali_13 , hope you have created an inactive/active  relationship between USERELATIONSHIP('MyReport'[Race], LegendCategories[Category]) or USERELATIONSHIP('MyReport'[Gender], LegendCategories[Category])

 

if the relationship is missing, then you get an error like above

 

example

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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