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
xiumi_hou
Post Partisan
Post Partisan

Please help! why the userelationship not working

Dear all,

 

I have two dimesion table(d_date and d_cases) both link to a fact table(f_call)

 

Now I want to use userelationship to build realtionship between my two dimesion tables. My goal is to use d_date as a slicer to filter the report, and count how many cases completion from cases table. But is gave error: USERELATIONSHIP function can only use the two columns references participating in relationship.

Below is my dax function: 

 

Count_Completed_Cases =
CALCULATE(
DISTINCTCOUNT(d_Cases[CaseNumber]),
d_Cases[Closure_reason_c] = "Completed",
USERELATIONSHIP(d_Cases[Closed_date_c],d_date[Date])
)
 
Thank you so much!
1 ACCEPTED SOLUTION

@xiumi_hou so after setting the relationship, did it worked?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
hnguy71
Memorable Member
Memorable Member

I believe the error is stating that you need either an active or inactive relationship that already has been set.  Only then will you be able to use the USERELATIONSHIP function. What you want actually would be to use TREATAS

 

So in your example, something like this:

 

Count_Completed_Cases =
CALCULATE(
DISTINCTCOUNT(d_Cases[CaseNumber]),
d_Cases[Closure_reason_c] = "Completed",
TREATAS(VALUES(d_Cases[Closed_date_c]),d_date[Date])
)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Thanks for the reply. When I changed the funtion, it gave below error, could you please help me check it? 

Too many arguments were passed to the VALUES function. The maximum argument count for the function is 1.

@hnguy71 

did you forget to close the parenthesis after VALUES?



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
parry2k
Super User
Super User

@xiumi_hou can you make sure you have relationship between d_cases[closed_date] with d_date[Date]

 

if you already have relationship between these two tables on other column, you still need to set relationship on closed_date which will be inactive.

 

There can be only one active relationship, but you can have more than one inactive relationships

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks Parry, it seems I forgot to create a new relationship and then use userelationship function. 

 

 

@xiumi_hou so after setting the relationship, did it worked?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.