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
Anonymous
Not applicable

How to deal with many to many relationships?

Hi, 

 

I would like to know the most efficient way of setting up the following relationship. I've been having troubles in understanding how to model a situation where multiple staff members work at multiple stores.

 

My tables are as follows

 

Store table:

StoreIdStore Name
1A
2B
3C
4D
5E
6F

 

Staff table: 

Where Staff Id is just a unique record identifier, staff code represents a unique staff member, store Id represents which store the staff member has worked at. Evidently, a single staff code can appear many times for multiple dealers.

Staff IdStaff CodeStore IdStaff Name
111111Jeff
211112Jeff
322222John
433333James
533336James
644444Ben
755555Kevin
866666Maria

 

Sales table: 

SalesIdStaff IdStaff CodeStore IdAmount
1111111$50
2211112$40
3111111$60
4322222$25
5866666$60
6533336$25
7433333$95
8644444$90

 

How do I set up these relationships so that I can use a slicer to select a store name, and display the staff members for that store, and their total sales amount only when they worked at that store? I have had troubles with inactive relationships and bi-directional filtering... 

 

Appreciate any help 🙂

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Supplement @FarhanAhmed 's reply.

Store table and Sales table based on Store ID.

Staff table and Sales table based on Staff ID.

 

how1.jpg

 

Then create a table visual and a slicer like this,

 

how2.jpg

 

how3.jpg

 

Please pay attention to the fields selected for each Visual.

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

3 REPLIES 3
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Supplement @FarhanAhmed 's reply.

Store table and Sales table based on Store ID.

Staff table and Sales table based on Staff ID.

 

how1.jpg

 

Then create a table visual and a slicer like this,

 

how2.jpg

 

how3.jpg

 

Please pay attention to the fields selected for each Visual.

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

FarhanAhmed
Community Champion
Community Champion

Since your Sales table already contains StoreID and Staff Code you can create the following relationship

 

Store-Sales -->1-Many (StoreId)

Staff-Sales --> 1-Many (StaffCode)

 

Use the Store from Store Table (Either in Slicer or Visual)

Use Staff from Staff table (Either in Slicer or Visual)

Use Sales Value from Sales Table.







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

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , it is it import mode , Create a contact column in both tables

 

Key = [Store Id] & "-"& [Staff Code]

 

And join on that. Assume at that time Staff to sales is One to Many.

If not you have to create a bridge Table

https://www.seerinteractive.com/blog/join-many-many-power-bi/

 

Other ways to take out a table from existing table (Power Query)

https://youtu.be/kU2M1LmNvNo
https://youtu.be/vHuhbvYCiNc

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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.