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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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