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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
zudar
Post Patron
Post Patron

Only preserve the longest & unique path in parent-child relationship

Hi all,

 

I'm a little confused by the following tutorial: Parent-child hierarchies – DAX Patterns.

 

The parent-child table looks like:

 

zudar_0-1623413619614.png

 

where:

 

 

EntityPath =
PATH ( Entity[EntityKey], Entity[ParentEntityKey] )

 

 

However, in my application of this concept.. I need to only preserve the longest unique path there is from the 'first' node.

 

So instead of results like (example):

 

1

1|1

1|9

2

2|4

2|4|8

2|4|8|9

3

3|5
3|6
3|5|8

4

 

I would like to see:


1|1

1|9

2|4|8|9

3|6
3|5|8

4

 

Is there a way to do this elegantly and directly through the PATH(...) -function?

3 REPLIES 3
zudar
Post Patron
Post Patron

Other suggestions are welcome 🙃

amitchandak
Super User
Super User

@zudar , there is pathlength function. with that, you can create a flag

 

You can use that

pathlen = pathlength([path])

 

new flag = if( maxx(filter(Table, [id] = earlier([ID])),[pathlen]) =[pathlen],1,0)

Which column(s) from the sample table would you use for [id] = earlier([ID])?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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