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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
afaro
Helper III
Helper III

How to find 2nd top most parent if topmost parent never exists in my data?

I am trying to use the PATH function in power bi but my data uses dummy values to denote when the top level parent. 

 

For example, 

 

child parent 

1         0

2         1

3         2

 

Here, 0th id doesn't exist. Now, this doesn't always have to be 0. It can be any number as parent id which is used as dummy where the hierachy is at the top and the parent with whichever id it is doesn't exist. 

 

Any way to go pass this issue? 

My object is to see the top parent here which would be 1 and not 0 (0 doesn't exist anyways) 

1 ACCEPTED SOLUTION
Irwan
Super User
Super User

hello @afaro 

 

looks like you need to do make rank or index to find 2nd top.

 

Here i modify your sample data.

Irwan_0-1721096487852.png

if the non-exist value is zero or blank, RANKX will count it as 1.

So the 2nd top  of your data will be the data with rank greater than 1.

 

i.e to find 2nd top most parent will be:

2nd Top Most Parent = CALCULATE(MIN('Table'[Parent "0"]),'Table'[Rank "0"]>1)

Irwan_1-1721096653589.png

it will calculate the minimum parent value with rank greater than one.

 

Hope this will help you.
Thank you.

View solution in original post

1 REPLY 1
Irwan
Super User
Super User

hello @afaro 

 

looks like you need to do make rank or index to find 2nd top.

 

Here i modify your sample data.

Irwan_0-1721096487852.png

if the non-exist value is zero or blank, RANKX will count it as 1.

So the 2nd top  of your data will be the data with rank greater than 1.

 

i.e to find 2nd top most parent will be:

2nd Top Most Parent = CALCULATE(MIN('Table'[Parent "0"]),'Table'[Rank "0"]>1)

Irwan_1-1721096653589.png

it will calculate the minimum parent value with rank greater than one.

 

Hope this will help you.
Thank you.

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors