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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
LoryMenCR
Helper I
Helper I

Codes and Group description codes table

Dear All,

i have two tables.

1) Codes

CodeDescription
0576Apple
0577Banana
0578Kiwi

 

2) Group classification of Codes

Parent Code 1Parent Code 2Parent Code 3Parent Code 4CodeGroup Description
1nullnullnullnullGroup Description A
11nullnullnullGroup Description B 
111nullnullGroup Description C
11110576Group Description D
11110577Group Description D
11110578Group Description D

 

Codes are unique both in table 1) and table 2).

 

What I want is relate this two tables so I can put a table/matrix viz where I can expand every Group Description A until every codes with their Group Description D associated.

 

Any idea?

Thanks

lorenzo 

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

Hi All,
Firstly  Kedar_Pande thank you for your solution!
And @LoryMenCR , As I understand it, you want to turn the Group Description column into a hierarchy, right? 
Then we can create a new table, and then use the Path function to give the column a hierarchical relationship and then nested to get the effect you want:

HierarchyTable = 
DATATABLE(
    "Child Description", STRING,
    "Parent Description", STRING,
    "Code", STRING,
    {
        { "Group Description C","Group Description D", 	"576" },
        { "Group Description C","Group Description D", "577" },
        { "Group Description C","Group Description D", "578"},
        
        { "Group Description B", "Group Description C", BLANK() },
        { "Group Description A","Group Description B",  BLANK()},
        { BLANK(),"Group Description A",  BLANK()}
        
    }
)
Path = PATH(HierarchyTable[Parent Description], HierarchyTable[Child Description])
Level1 = PATHITEM(HierarchyTable[Path], 4, TEXT)

 

vxingshenmsft_0-1732092476226.png

Once we have the exact relationship, we can connect our HierarchyTable to Code to form a one-to-many relationship to get the results we need, and finally use a measure to get the right results.

Measure = IF(
    NOT(ISINSCOPE('HierarchyTable'[Code])),
    BLANK(),
    LOOKUPVALUE(Code[Value],'Code'[Code],SELECTEDVALUE('HierarchyTable'[Code])))

vxingshenmsft_1-1732092633672.png

If you have further questions, you can check the pbix file I uploaded, I hope my method can help you, I would be honored if I can solve your problem!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

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

 

 

 

View solution in original post

2 REPLIES 2
v-xingshen-msft
Community Support
Community Support

Hi All,
Firstly  Kedar_Pande thank you for your solution!
And @LoryMenCR , As I understand it, you want to turn the Group Description column into a hierarchy, right? 
Then we can create a new table, and then use the Path function to give the column a hierarchical relationship and then nested to get the effect you want:

HierarchyTable = 
DATATABLE(
    "Child Description", STRING,
    "Parent Description", STRING,
    "Code", STRING,
    {
        { "Group Description C","Group Description D", 	"576" },
        { "Group Description C","Group Description D", "577" },
        { "Group Description C","Group Description D", "578"},
        
        { "Group Description B", "Group Description C", BLANK() },
        { "Group Description A","Group Description B",  BLANK()},
        { BLANK(),"Group Description A",  BLANK()}
        
    }
)
Path = PATH(HierarchyTable[Parent Description], HierarchyTable[Child Description])
Level1 = PATHITEM(HierarchyTable[Path], 4, TEXT)

 

vxingshenmsft_0-1732092476226.png

Once we have the exact relationship, we can connect our HierarchyTable to Code to form a one-to-many relationship to get the results we need, and finally use a measure to get the right results.

Measure = IF(
    NOT(ISINSCOPE('HierarchyTable'[Code])),
    BLANK(),
    LOOKUPVALUE(Code[Value],'Code'[Code],SELECTEDVALUE('HierarchyTable'[Code])))

vxingshenmsft_1-1732092633672.png

If you have further questions, you can check the pbix file I uploaded, I hope my method can help you, I would be honored if I can solve your problem!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

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

 

 

 

Kedar_Pande
Resident Rockstar
Resident Rockstar

@LoryMenCR 

Create a one-to-many relationship:
Codes[Code] → Group Classification[Code].

 

Add a calculated column

FullHierarchy = 
CONCATENATE(
CONCATENATE(
CONCATENATE(
IF(ISBLANK('Group Classification'[Parent Code 1]), "", 'Group Classification'[Parent Code 1] & " > "),
IF(ISBLANK('Group Classification'[Parent Code 2]), "", 'Group Classification'[Parent Code 2] & " > ")
),
IF(ISBLANK('Group Classification'[Parent Code 3]), "", 'Group Classification'[Parent Code 3] & " > ")
),
'Group Classification'[Group Description]
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Helpful resources

Announcements
Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.