Meera k
Moderator
Moderator

How to manually create hierarchy in PowerBI with Custom sorting

Creating a hierarchy manually in Power BI allows you to organize and group data fields in a parent-child relationship, which can help visualize data more effectively in reports.

Steps to Create a Hierarchy in Power BI:

Step1. Prepare Data

ID and Parent ID needs to be Numeric.

Level 0 ID to Level 4 ID for Sorting each hierarchy.

Step2. In the Power BI, ensure you have your data loaded into the model.

Create New Column using Path function, to track each hierarchy

 

Step3. Now create New column for each Level

Level 0 to Level 4 in the above example.

DAX for Level 0:

Level 1:

Level 2 :

Level 3 :

Level 4 :

Step4. Now for each Level , will give sort with respective Level ID column.

Like Level 1 will sort on “Level 1 ID”

Similarly, will do sorting for all the Levels.

Step5. Next, create the hierarchy using all the created Levels in Table View.

Step6. Now simply drag and drop the hierarchy in the report to view hierarchical structure.

The hierarchy will automatically expand to allow users to drill down from the top level  to the lower levels with custom sorting.

2