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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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