Forum Discussion
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:
Relationships (one-to-many):
Formula when one-to-many (correct result):
Relationships (one-to-one):
Formula when one-to-one (incorrect result):
4 Replies
- MFelixSuper 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/
- parry2kSuper 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.⚡
- Zyg_DContinued 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.
- AnonymousNot applicable
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