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
afaro
Helper III
Helper III

Viewing the data as a hierarchy for data which has an internal hierarchy

I have data like this 

 

KeyTransaction IDParent Transaction ID
K132
K121
K110
K232
K221
K210

 

I want to identify the level 1 parent for all of these but as the transaction ID itself is not unique but it is unique per Key then how do I go about doing this? 

I want to use the PATH and PATHITEM variables for this? Also, how do I create a hierachy if the number of levels is unknown to me? 

1 REPLY 1
Anonymous
Not applicable

Hi @afaro

 

Step 1: Create a Unique Identifier

Given your description, you might concatenate the Key and Transaction ID,Parent Transaction ID to form a unique identifier for each transaction. For example, you can create a new column in Power Query or using DAX:

UniqueID = [Key] & [Transaction ID]
ParentUniqueID = [Key] & [Parent Transaction ID]

 

Step 2: Use PATH to Create Hierarchy

Once you have unique identifiers, use the PATH function to create a hierarchy path. The PATH function requires two parameters: the unique identifier of the current row and the unique identifier of the parent row.

HierarchyPath = PATH([UniqueID], [ParentUniqueID])

 

Step 3: Identify Level 1 Parent

To identify the level 1 parent, use the PATHITEM function. This function extracts an item from the path created by PATH, based on its position. Since you're interested in the level 1 parent, you would use:

Level1Parent = PATHITEM([HierarchyPath], 1) 

Best Regards,

Jayleny

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.