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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
PetyrBaelish
Resolver III
Resolver III

How to use USERELATIONSHIP correctly

I have been trying to use USERELATIONSHIP, but can't get it working in my example below. This is for a Power BI report with a live connection to a SSAS tabular model:

 

My data is as follows:

Userelationship - Data.PNG

 

 

From the 3 tables above, there is a relationship between the Incident Facts table and Incident Details table on the Incident ID column.

There is an inactive relationship between the Dates table (DatesKey) and Incident Facts table (CompletedDateKey).

 

I have the following measures on the Incident Facts table:

 

RatingAverage:=CALCULATE(AVERAGE('Incident Details'[FeedbackRating]),filter('Incident Details','Incident Details'[RatingGiven]=TRUE),USERELATIONSHIP('Incident Facts'[CompletedDateKey],Dates[DateKey]))

 

RatingGivenCount:=CALCULATE(COUNTAX(FILTER('Incident Details','Incident Details'[RatingGiven]=TRUE),'Incident Details'[RatingGiven]),USERELATIONSHIP('Incident Facts'[CompletedDateKey],Dates[DateKey]))

 

RatingGivenPercent:=CALCULATE(IF('Incident Facts'[Completed]<>0,'Incident Facts'[RatingGivenCount]/'Incident Facts'[Completed]*100,""),USERELATIONSHIP('Incident Facts'[CompletedDateKey],Dates[DateKey]))

 

Completed:= CALCULATE(COUNTROWS('Incident Facts'),FILTER('Incident Facts','Incident Facts'[Completed]=1),USERELATIONSHIP('Incident Facts'[CompletedDateKey],'Dates'[DateKey]))

 

The Completed measure is working perfectly. For the others however, when I place them into a table visualisation with Year-Month and Date from the Dates table and the 4 measures above only the Completed measure is accurately breaking down per month/date. RatingAverage and RatingGivenCount are showing the same value for every entry and RatignGivenPercent is also inaccurate (I can see that it's dividing between a static RatingGivenCount and a dynamic Completed).

 

My question is, why aren't my RatingAverage, RatingGivenCount and RatingGivenPercent measures relating to my dates table?

 

Here an example of the ouput:

Userelationship - Data2.PNG

 

1 ACCEPTED SOLUTION

Hi @v-lili6-msft,

 

I figured out the problem while preparing a test pbix file - it was my relationships (Incident Facts was on the many side of many to one relationships with both of the other tabels). Changing the Incident Details to Incident Facts relationship as a 1:1 relationship has solved my problem.

 

Thanks for your help.

View solution in original post

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi, @PetyrBaelish 

For [Completed] and [RatingGivenPercent] works well but [RatingAverage] and [RatingGivenCount] doesn't.

So i think there should be something wrong on other side.

Could you please import some sample data and do a simple sample pbix file (just could reproduce the issue) for us have a test?

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-lili6-msft,

 

I figured out the problem while preparing a test pbix file - it was my relationships (Incident Facts was on the many side of many to one relationships with both of the other tabels). Changing the Incident Details to Incident Facts relationship as a 1:1 relationship has solved my problem.

 

Thanks for your help.

v-lili6-msft
Community Support
Community Support

hi, @PetyrBaelish 

You may try to change conditional 'Incident Details'[RatingGiven]=TRUE to 'Incident Details'[RatingGiven]="Yes"

And then it will work well.

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Lin,

 

My original post was inaccurate. The RatingGiven column is actually a TRUE/FALSE column as per below:

 

=IF(ISBLANK('Incident Details'[FeedbackRating]),FALSE,TRUE)

 

I have tried using "Yes"/"No" and TRUE/FALSE but neither is producing the output I'm expecting (which is different figures for different months).

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.