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

The Fabric community is upgrading! Read all of the details including the timeline and what you can expect. Learn more

Reply
mgost
Frequent Visitor

Multiple relationships between 2 tables

Hi everyone,

 

I really need your help. I am stuck.

I need to calculate Amount by User in Document Number, but user can occur in any of three columns - First User, Second User or Third user. I cannot filter Document Number and Amount by User from User table, because I can't have ambigous relationship between table Delivery Header and User table. How can I make relationship between these tables?


Mapiranje atributa artikala(1).png

 

or directly in measure if user appears in First User => sum this amount and document number etc...
I have lost one day and I can't figure it out...
Thanks!

8 REPLIES 8
Anonymous
Not applicable

Hi,

 

For the data model:

 

Can you merge your Delivery Order (Header) table into the Delivery Line Item (Detail) table? That would simplify your model.

 

If not, you can still use an active relationship on User 1, and inactive relationships on User 2 and User 3 against your User dim table.

Screenshot 2024-11-28 160707.png

 

Then, for the measures:

 

Maybe do the User count in your Delivery Order table as a calculated column

Screenshot 2024-11-28 155600.png

 

And for your question 1 :

That is just a simple summation:  SUM(DocDetail[Amount])

 

For question 2 - Check user name and sum:

SUM using USERELATIONSHIP

Screenshot 2024-11-28 161828.png

 

For Question 3 - If user count = 3...then divide by 3

You could use a summarized table and wrap that in a SUMX measure to get the result you want. (here i just made a table)

Screenshot 2024-11-28 162124.png

 

Thank you very much, it is on good track, but if i use it in table in visual i still get only documents shown for user where user is in first name column. In my model, here are shown 4 documents for the user and he has deliverd 7 documents(in 3 other documents he is in second column-second name). how can i show all 7 when i use filter "Users"
filtered.png

Anonymous
Not applicable

Hi,

 

To display and filter records like that, i think you need to change the approach to use a bridge table.  That will also make your dax measures more simple as you dont need to use "if" & "userelationship".

 

In your power query, create a new table from the User1, User2, User3 and Doc columns only then unpivot so you only have the two columns of Doc and User remaining.

 

In the data model, set the relationships so they are active and the DocHeader relationship is Bi-directional.

 

Screenshot 2024-12-03 144552.png 

Anonymous
Not applicable

Hi @mgost ,

 

I'm assuming the data in the Delivery Order table looks like this:

vcgaomsft_0-1732777275983.png

If so, select the three User columns, right click and click the unpivot columns:

vcgaomsft_1-1732777396074.png

Then filter out Blank.

vcgaomsft_2-1732777476415.png

Relationship:

vcgaomsft_3-1732777639029.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thank you for your reply, but I would also use unpivot to manage these 3 columns-that is my backup solution. The problem is that my Delivery Order table using unpivot is growing in size. I want to keep it as it is, because data model is already big. Is there any way to use three relationships on delivery order from users? i tried with 2 inactive realtionships and of course, and with USERELATIONSHIP but it gives error because it is then ambigous relationship... 

mgost
Frequent Visitor

this is my code, that doesn't work...

code.png

ajohnso2
Solution Supplier
Solution Supplier

Can you provide some sample data from your three tables that will show this issue you have?

Sorry I can't share company data, and don't have so much time to recreate everything with dummy data.
but here is detailed diagramm:

Mapiranje atributa artikala(2).png

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.