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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
likhitha2705
Frequent Visitor

Removing Blank rows in the middle hierarchy in Matrix

Hello Team,
I've a product Hierarchy like this.
Category->Sub Category->Product Name.
Few Categorirs have Sub Categories but not Products,
Few Categories have Products but not Sub Categories. And the data looks like this.

likhitha2705_0-1729494256656.png

For Accessories there's no Sub category but Products are there.In my output I want to see Accessories followed by the Acceessories Products but not the Blank.
I'm using the below DAX

Sales_Test =
SWITCH(TRUE(),
ISINSCOPE(Sheet1[Product Name])&&SELECTEDVALUE(Sheet1[Product Name])=BLANK(),BLANK(),
ISINSCOPE(Sheet1[Sub Category])&&SELECTEDVALUE(Sheet1[Sub Category])=BLANK(),BLANK(),
ISINSCOPE(Sheet1[Category])&&SELECTEDVALUE(Sheet1[Category])=BLANK(),BLANK(),SUM(Sheet1[Sales]))
But the output show like this
likhitha2705_1-1729494559624.png

In my output I want to see Accessories followed by the Acceessories Products.And for the rest of the Category the output is correct.
Let me know how to achieve this.
TIA


1 ACCEPTED SOLUTION

Heya @likhitha2705 ,

See attached file. I've simply created two calculated columns as previously mentioned. However, if your data is too big, if you have thousands of entries and tenths of these blank situations then you may want to consider a different approach. Never the less, the cleaner the hierarchy, the cleaner the output.



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

View solution in original post

4 REPLIES 4
likhitha2705
Frequent Visitor

Hi @MNedix 
Thanks for the reply .Somehow I'm little confused with your solution. If possible can attach the pbix file for the above.
TIA

CategorySub CategoryProduct NameSales
Accessories Bike Wash1000
Accessories Fender Set2000
Accessories Helmet3000
BikesMountain Bikes 2500
BikesRoad Bikes 3000
BikesTouring Bikes 4500
ClothingCapsLogo Cap5000
ClothingGlovesFinger Gloves4300
ClothingJerseysLong Sleeve Jersey3500

Heya @likhitha2705 ,

See attached file. I've simply created two calculated columns as previously mentioned. However, if your data is too big, if you have thousands of entries and tenths of these blank situations then you may want to consider a different approach. Never the less, the cleaner the hierarchy, the cleaner the output.



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,
likhitha2705
Frequent Visitor

Hi @MNedix 
Thanks for the reply .Somehow I'm little confused with your solution. If possible can attach the pbix file for the above.
TIA

CategorySub CategoryProduct NameSales
Accessories Bike Wash1000
Accessories Fender Set2000
Accessories Helmet3000
BikesMountain Bikes 2500
BikesRoad Bikes 3000
BikesTouring Bikes 4500
ClothingCapsLogo Cap5000
ClothingGlovesFinger Gloves4300
ClothingJerseysLong Sleeve Jersey3500
MNedix
Super User
Super User

Heya,

To be sure you get accurate and correct results from your data you should clean it up first and make it consistent across the tables. The first thing you should do is complete/clean-up your hierarchy: create calculated Sub-Categories for orphan Products and add Products where you have none. 
For example, you could use a Switch function to create a Subcategory from Products - for example:

Sub-Category = 
SWITCH(
TRUE(),
[Product] = "Bike Wash", "Bike accessories",
[Product] = "Fender Set", "Bike accessories",
[Product] = "Helmet", "Bike accessories")

 You can also create a Product from Sub-Category, like this:

Product=
IF(ISBLANK([Product]),[Sub-Category])

The above will allow you to:

1. Clean up the orphan Products.

2. Have prices correctly associated with Products rather than Categories or Sub-Categories

 

Then you could start building a proper hierarchy structure, calculate the PATH and use ISINSCOPE to correctly display the table/values.



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors
Top Kudoed Authors