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
aid928
Helper I
Helper I

Relationship between two tables based off multiple columns?

Hi all,

 

Hoping someone can help me with this one as it's really got me stuck.

 

Basically I have four tables. One table is a Cost Centre hierarchy, with high level codes feeding into lower level codes (L5 is a bottom level Cost Centre).

 

L1L2L3L4L5
112123123412345
112123123412333
112123123912392
115154154415448
222224224822482

 

Two other tables are Account Code and Activity coce hierarchies with a similar layout to the above.

 

I then have a Posting Rules table, where a Posting Rule can exist at any level in the hierarchy.

 

CCACCACT
1xyy
1xxyy
12345xyy
2248xxxyy
2248xxyy
22xxyy

 

Having real difficulty getting these tables linked. Even just focusing on the Cost Centre table, because a Posting Rule can sit at any level in a hierarchy, I'm not able to build a relationship between single columns.

 

We essentially want a user to be able to select a bottom level (L5) Cost Centre from a slicer (say 12345), and then see all Posting Rules directly against it, or that feed up through the hierarchy, so this would produce:

 

CCACCACT
1xyy
1xxyy
12345xyy

 

Any help to come to this solution would be greatly appreciated.

 

Thanks!

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @aid928 
Please follow the steps and refer to attached sample file

3.png1.png2.png4.png1.png

 

View solution in original post

10 REPLIES 10
aid928
Helper I
Helper I

Hi tamerj1,

 

Thanks very much for producing this - I tried downloading the file but because we are on Power Bi Report Server and your file has many-to-many relationships, I'm unable to open it.

 

Are you able to explain how you linked the two tables together?

 

Thanks so much

@aid928 
From the model view just drag the CC from table to the other CC in the other table.

Hi @tamerj1 

 

Thanks again for explaining this, really useful for understanding.

 

Do you know if there would be any way to achieve this without a many to many relationship? Since we are on PBI Report Server I can't make a many to many relationship.

 

Thanks,

 

Aidan

@aid928 
Yes but would it be ok to have 1:* relationship but 2way?

Nope, says I can't make a relationship since the matching columns arent unique

@aid928 
I mean something like this

1.png

You vcan use power query or dax to create a unique table and use it as a bridge table. Would this make sense to you?

Ah apologies again, I had the relationship going to the wrong field. Have got it working, thank you so much!

Ah sorry have tried that now. Should my slicer still use the CC field from the Cost Centre table? When doing this and filtering against CC 12345, I am only getting Posting Rules directly against it rather than including CC 1 also.

@aid928 
The slicer is from 'Cost Center'[L5] column

tamerj1
Super User
Super User

Hi @aid928 
Please follow the steps and refer to attached sample file

3.png1.png2.png4.png1.png

 

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.