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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
AGo
Post Patron
Post Patron

First hierarchical nonblank value

Hello,

I've got a table with these columns:  ParentID(text), ID(text), Attribute(text).

For each ID I need the first upper hierarchical non-blank Attribute to be returned in a calculated column.

eg. if Attribute of a row is blank, suppose that this row is logically at the 6th hierarchy depth level, the function will scan Attribute at its related level 5,4,3.... and so on, until it finds a non-blank value.

For now I know I have max 15 fixed depths of hierarchy, but I hope there's a function that can dynamically calculate what I need, regardless of the possible depths determined by the database structure.

Is it possible in PowerBI?

Thanks!

3 REPLIES 3
Anonymous
Not applicable

First, in PBI the only way to implement parent-child hierarchies is to expand them to fixed-depth hierarchies. I hope you're aware of this. So you have to flatten the hierarchy. Once you've got this flat structure, it should be pretty easy to achieve what you want by very standard means.

 

For how to turn a parent-child hierarchy into a flattened one please find an article on www.sqlbi.com. Just type "parent child" into the search box and you should be presented with a handful of articles.

 

Also, please remember that you can unpivot your structure into a second (hidden) table and from such a table it should be easy to calculate what you want.

 

Best
D

Greg_Deckler
Community Champion
Community Champion

Should be, check out the PATH function.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Yes, I tried, but I think it is a fundamental part of a more complicated function to be written.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.