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
Zyg_D
Continued Contributor
Continued Contributor

USERELATIONSHIP does not work on one-to-one

The function USERELATIONSHIP nicely works when the top right relationship is one-to-many. But when I change it to one-to-one, the USERELATIONSHIP does not yield correct results. Why? It should not be affected at all, in my opinion. 

Data:

Tables.JPG

Relationships (one-to-many):

relationships-works.JPG

Formula when one-to-many (correct result):

formula-one-to-many.JPG

Relationships (one-to-one):

relationships-no-work.JPG

Formula when one-to-one (incorrect result):

formula-one-to-one.JPG

 

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @Zyg_D ,

Please review the following documentations and check if they can help you.

Create and manage the relationship

The Cardinality of Power BI Relationship Demystified

One-To-One Relationships In Power BI

Best Regards

Rena

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

Hi @Zyg_D ,

 

This is related with the way that the USERELATIONSHIP works, the function is used as a context transaction and the calculated columns force this to be a row context so the calculation will give inacturated values.

 

Check the blog post of SQL BI with a full detail on this, and that suggest in this case the use of LOOKUPVALUE or the use of CALCULATETABLE depending on expected results.

 

https://www.sqlbi.com/articles/userelationship-in-calculated-columns/


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



parry2k
Super User
Super User

@Zyg_D first and foremost question, since this relationship is active, not sure why you are using USERELATIONSHIP, and 2nd you don't need to use MAX function, you can simply use RELATED function to get value from One side of the relatioship.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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.

Zyg_D
Continued Contributor
Continued Contributor


@parry2k wrote:

@Zyg_D first and foremost question, since this relationship is active, not sure why you are using USERELATIONSHIP, and 2nd you don't need to use MAX function, you can simply use RELATED function to get value from One side of the relatioship.

In the USERELATIONSHIP I am trying to use the bottom right relationship. However, I see that the top right one affects my results, which is bizzare.

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.

Top Solution Authors