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
Minu_Latha
Frequent Visitor

Power Bi hierarchy from 2 different tables

How to define a hierarchy in slicer from 2 different tables where we have Unique records in master table and relationship from these table to main table columns.

Say for eg Main table has Personnel has column Employee,Country,State

Master Tables Country with column Country Name,Country Code 

& State with column State Code,State Name

 

Both Master tables have relationship to Personnel by Column country & State

 

I need a slicer having hierarchy of Country,State from 2 Master Tables

1 ACCEPTED SOLUTION

Hi, @Minu_Latha 

Thank you very much for your information.

I have a few times faced this types of situation, for instance, skill levels under different skill sets.
I saw some people using custom-visualizations for a slicer, but what I normally do is,

 

1. Import source data to Power Query Editor

Picture1.png

 

2. reference the origin table -> remain only three columns create dim-table 

Picture2.png

 

3. select all three columns and remove duplicates. In this case, there was no C group1 in the original file. However, when the original file is updated, then the dim-table will be also updated. Because it is not duplicated, but it is referenced.

Picture3.png

4. create index column -> each line is unique.

Picture4.png

5. reference the original table and rename it to Employees.  Then make original table to disable upload.

Picture5.png

In the Employees table, bring the index number from the dim-table by using merge. Then delete group1 / group2 / group3 columns.

Picture6.png

Load two tables and create the relationship like below.

Picture7.png

 

from here, the below described hierarchy-type-slicer can be easily created. 

Picture8.png

 

the link to my sample pbix file is down below.

It is not a very fancy way to solve it, but it works. I hope this helps. 

 

https://www.dropbox.com/s/1ss7rp0901npsx9/Minu_Latha%202021%200323.pbix?dl=0 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

9 REPLIES 9
technolog
Super User
Super User
Jihwan_Kim
Super User
Super User

Hi, @Minu_Latha 

Please correct me if I wrongly understood.

You know your data model much better than me, and what I have understood is that I like to suggest deleting two Country and State tables, and create one table that comes from Main Table. this new table has to contain Country name / Country code / State name / State code.

 

In this case, I believe you can create a hierarchy-type slicer.

If you can share your sample pbix file, I can try to look into it and come up with a desirable solution.

 

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

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Then The Master table model will be 

Country Name  State Name

A                          B

A                          C

A                          D

 

Then how will we link this to main table since country not unique(Relationship)

Hi, 

I think the State Name is unique.

Can I try to connect between StateName/Mastertable and StateName/Maintable ?

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Actually my Data model is like this

Master Table Group 1
NAME
A
B
C

Master Table Group 2
Name
AA
BB
CC

Master Table Group 3
NAME
AAA
BBB
CCC
Linking Table between all three master table(Junction Table)

Group 1   Group2 Group 3
A               AA        AAA
A               AA        BBB
B               BB        BBB
B               BB        CCC
C               CC       CCC
C               CC       AAA

Main Table(Employee)

Employee Name Group1 Group2 Group3 Year
S                           A           AA         AAA     2010
P                           A           AA         BBB      2010
R                           A           AA         AAA     2010
T                            B           BB         BBB      2011
Q                           B           BB         CCC      2011
D                           B           BB         BBB       2011


How should I link all the tables to get a slicer with hierarchy BASED ON Junction table
Group1,Group2,Group3
A
    AA
          AAA
          BBB
B
    BB
          BBB
          CCC
C
    CC
          CCC
          AAA


And this hierarchy slicer must filter the main table(Employee)


How should I change the relationships.Can you help 

@Minu_Latha 

 

You can just drag the fields from your table directly into a slicer to get the hierarchy:

multi slicer.JPG





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi, @Minu_Latha 

Thank you for your questions.

May I ask, 

In the master table,

- AAA is under AA, and at the same time under CC as well?
- BBB is under AA,  and at the same time under BB as well?

- CCC is under BB, and at the same time under CC as well?

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Thanks for you Spontaneous response.

Yes your understanding is right,

 

The hierachy level for Group1-First Level,Group2-Second Level,Group3-Third level is

A
    AA
          AAA
          BBB
B
    BB
          BBB
          CCC
C
    CC
          CCC
          AAA

Hi, @Minu_Latha 

Thank you very much for your information.

I have a few times faced this types of situation, for instance, skill levels under different skill sets.
I saw some people using custom-visualizations for a slicer, but what I normally do is,

 

1. Import source data to Power Query Editor

Picture1.png

 

2. reference the origin table -> remain only three columns create dim-table 

Picture2.png

 

3. select all three columns and remove duplicates. In this case, there was no C group1 in the original file. However, when the original file is updated, then the dim-table will be also updated. Because it is not duplicated, but it is referenced.

Picture3.png

4. create index column -> each line is unique.

Picture4.png

5. reference the original table and rename it to Employees.  Then make original table to disable upload.

Picture5.png

In the Employees table, bring the index number from the dim-table by using merge. Then delete group1 / group2 / group3 columns.

Picture6.png

Load two tables and create the relationship like below.

Picture7.png

 

from here, the below described hierarchy-type-slicer can be easily created. 

Picture8.png

 

the link to my sample pbix file is down below.

It is not a very fancy way to solve it, but it works. I hope this helps. 

 

https://www.dropbox.com/s/1ss7rp0901npsx9/Minu_Latha%202021%200323.pbix?dl=0 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking 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.