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

Parent-child matrix visualization with parent as first child row

Given the following table

IDParent IDAMOUNTPATH
1 101
21201|2
31301|3
42401|2|4
52501|2|5

 

I want to create a Parent-Child visualization using matrix in Power BI.

 

Currently using DAX method PATH and PATHITEM I have this:

  ID                 Amount       

   1                  150

     2                110

           4          40

           5          50 

     3                30

 

Is it possible to have :

  ID                  Amount       

   1                   150

       1               10

       2               110

           2           20

           4           40

           5           50 

       3               30

 

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

Hi, @Anonymous 

 

Based on your description, I created data to reproduc your scenario. The pbix file is attached in the end.

Table:

b1.png

 

You may create calculated columns as below.

Path = PATH('Table'[ID],'Table'[Parent ID])
Level1 = PATHITEM('Table'[Path],1,TEXT)
Level2 = 
var _level2 = PATHITEM('Table'[Path],2,TEXT)
return
IF(
    PATHITEM('Table'[Path],2,TEXT)="",
    [Level1],
    _level2
)
Level3 = 
var _level3 = PATHITEM('Table'[Path],3,TEXT)
return
IF(
    _level3="",
    IF(
        [Level2]="",
        [Level1],
        [Level2]
    ),
    _level3
)

 

Result:

b2.png

 

Best Regards

Allan

 

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

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduc your scenario. The pbix file is attached in the end.

Table:

b1.png

 

You may create calculated columns as below.

Path = PATH('Table'[ID],'Table'[Parent ID])
Level1 = PATHITEM('Table'[Path],1,TEXT)
Level2 = 
var _level2 = PATHITEM('Table'[Path],2,TEXT)
return
IF(
    PATHITEM('Table'[Path],2,TEXT)="",
    [Level1],
    _level2
)
Level3 = 
var _level3 = PATHITEM('Table'[Path],3,TEXT)
return
IF(
    _level3="",
    IF(
        [Level2]="",
        [Level1],
        [Level2]
    ),
    _level3
)

 

Result:

b2.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Thank you @v-alq-msft  that's what I wanted to do.

Just one last thing is it possible to avoid to repeat the node "1"  three times?

(-)1  

    1

instead of

(-)1

     (-)1

           1

 

amitchandak
Super User
Super User

@Anonymous , refer if this can help

https://www.thebiccountant.com/2019/10/03/parent-child-hierarchies-with-multiple-parents-in-power-bi-with-power-query/

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

Thank you @amitchandak for your reply but in my case I don't have mutliple parents, when I unfold a parent node I just want to display the parent node among the children nodes, because the parent node has his own "amount" to display.

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.