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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
bikelley
Helper IV
Helper IV

How to create a Parent/Child hierarchy for accounts Id?

Hello,

 

I need to create a parent and child hierarchy, but only some of the accounts have multiple branches. Basically, most of them don't have parents. Please see the below data. I am kinda stuck with logic, and getting some errors.

 

So my ID column has a bunch of IDs and the only way we know that Id is a child is the Preant_Id column has parent Id value.

Please advise me or show me how to do it. I need to get the name as well, but I think I do it to join the same table with parent ID.

 

Sample File - 

https://drive.google.com/file/d/1XQPJPx0CwovTg3T_N3WuO0SocEP-RXAG/view?usp=sharing

 

What I tried so far - 

Column = IF(Sample_dim[Parent_Id] <> "", Sample_dim[Parent_Id], Sample_dim[Id])
Path = PATH(Sample_dim[Id],Sample_dim[Parent_Id])

Sample Data

Untitled.jpg

 

Thank you so much for the help 

1 ACCEPTED SOLUTION
bikelley
Helper IV
Helper IV

I found a way to fix the error. 

First, you need to duplicate the table, remove all columns except parent Id. Then remove duplicated, rename it to ID  then append it to the main table. It will fix the issue. 

 

Basically, you going to insert parent ID into the id column, then remove dups. 

 

Thank you for all your help. 

View solution in original post

5 REPLIES 5
bikelley
Helper IV
Helper IV

I found a way to fix the error. 

First, you need to duplicate the table, remove all columns except parent Id. Then remove duplicated, rename it to ID  then append it to the main table. It will fix the issue. 

 

Basically, you going to insert parent ID into the id column, then remove dups. 

 

Thank you for all your help. 

sevenhills
Super User
Super User

To know about path and hierachy info,
https://docs.microsoft.com/en-us/dax/understanding-functions-for-parent-child-hierarchies-in-dax

 

https://simplebiinsights.com/power-bi-path-function-for-parent-child-hierarchies-in-dax/

 

During my quick review, I saw your data having gaps ... so I was not able to use Path  

@sevenhills 

 

Hi, Thank you for taking look at my issue. Yes, I don't have a parent-child hierarchy for every single raw. I just want if they have parent id then create child hierarchy. I also tried PATH did not work for me.

 

Let me take a look at your other solution. Thank you so much

sevenhills
Super User
Super User

Parent Name =
VAR RowParent =
    SELECTEDVALUE ( Sample_dim[Parent_id] )
RETURN
    IF (
        ISBLANK ( RowParent ),
        "",
        LOOKUPVALUE ( Sample_dim[Name], Sample_dim[Id], RowParent )
    )

(as measure)

 

 

Parent Name =
VAR RowParent =
    Sample_dim[Parent_id] 
RETURN
    IF (
        ISBLANK ( RowParent ),
        "",
        LOOKUPVALUE ( Sample_dim[Name], Sample_dim[Id], RowParent )
    )

(as column)

@sevenhills 

Hi, I try creating a measure and column and did not work for me. It is not showing me the child id if they have parent id (I mean it should show plus sing on parent id name then you will see child id name).

Am I doing something wrong? please correct me if I doing it wrong. 

 

Sample file with calculated column and measures

https://drive.google.com/file/d/1erJfJN4FDCgvxVkla_AmrSd4f2yzt0ZP/view?usp=sharing

 

Image

Untitled.jpg

Thank you so much for your time and help. I really appreciate it. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors