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
WaleedBinAli
Frequent Visitor

Create hierarchy with one column only

Hi everyone, i am using community for the very first time so if you don't understand my query please reply me back so i can let you know. I want to create hierarchy from one column. The image is attached below, as you can see there are different forms of revenue given below. I have create a table from visuals which include Total Revenue which i get by filtering the row it was simple. Now I want hierarchy when i click total revenue it gives drop down menu of revenue and then when i click revenue it give rest of the revenue's for exampe revenue normal work etc. Please share any strategy of how to do it or code.

 

 

onecolhierarchy.PNG

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @WaleedBinAli ,

 

Does your Expense column all end at a level in the Total row? If yes, you can try extracting the Total rows and then padding them up to get a hierarchy.

1.Add a conditional column to get the row contains 'Total'.

vstephenmsft_0-1660722086324.png

2.Fill up.

vstephenmsft_1-1660722143686.png

vstephenmsft_2-1660722231546.png

3.You can remove the 'Total' by adding a custom column.

vstephenmsft_3-1660722361924.png

vstephenmsft_5-1660722565850.png

 

4.Trim the column to remove the space.

vstephenmsft_6-1660722612747.png

vstephenmsft_4-1660722545850.png

Then the problem is that the first and last lines of each group are not needed, such as "Revenue" and "Total Revenue". The solution is to sort in groups and then delete the first and last lines, which I will not describe in detail here. You can view my attachments and go to Power Query to see the detailed steps.

This is the final result.

vstephenmsft_7-1660723219053.png

vstephenmsft_8-1660723289337.png

 

 

Best Regards,

Stephen Tao

 

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

 

 

 

 

View solution in original post

5 REPLIES 5
v-stephen-msft
Community Support
Community Support

Hi @WaleedBinAli ,

 

Does your Expense column all end at a level in the Total row? If yes, you can try extracting the Total rows and then padding them up to get a hierarchy.

1.Add a conditional column to get the row contains 'Total'.

vstephenmsft_0-1660722086324.png

2.Fill up.

vstephenmsft_1-1660722143686.png

vstephenmsft_2-1660722231546.png

3.You can remove the 'Total' by adding a custom column.

vstephenmsft_3-1660722361924.png

vstephenmsft_5-1660722565850.png

 

4.Trim the column to remove the space.

vstephenmsft_6-1660722612747.png

vstephenmsft_4-1660722545850.png

Then the problem is that the first and last lines of each group are not needed, such as "Revenue" and "Total Revenue". The solution is to sort in groups and then delete the first and last lines, which I will not describe in detail here. You can view my attachments and go to Power Query to see the detailed steps.

This is the final result.

vstephenmsft_7-1660723219053.png

vstephenmsft_8-1660723289337.png

 

 

Best Regards,

Stephen Tao

 

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

 

 

 

 

Thanks done with switch statements it was easy thanks alot

 

WaleedBinAli
Frequent Visitor

Thanks for answering @ChristianDGreat. Will let you know brother. 

ChristianDGreat
Resolver I
Resolver I

Theres lots of ways to do Hierarchy in Power BI.

 

You can use Group, so on the column on the right pannel go to the column you want to group and right click and create group.

Another one is creating your logic using New Columns and you can add your formula like. IF's and Switch.

Do you have an example for both which help me

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.