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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
un97
Regular Visitor

Hierarchy skip (not hide) blank rows

Hi, my data looks something like the table below. With Lvl1 being the highest in the heirarchy and Lvl5 being the lowest.  

 

TABLE:

IDLvl1Lvl2Lvl3Lvl4Lvl5
1CostsFinancial ExpensesFees Bank charges
2CostsOther ExpensesOther ServicesIT ServicesSecurity
3CostsPersonel ExpensesHiring Costs Recruitment
4CostsAdmin ExpensesProperty Insurance Insurance Other
5CostsFinancial ExpensesTransport Transport

 

I also have a DAX measure: COUNTROWS(TABLE)

 

I need to create a matrix that shows the heirarchy of these levels and how many rows each level has. If I only add all the levels to Rows of the matrix, I get a blank row for the blanks in Lvl4, but I can still expand that row to see the values from Lvl5. 

 

What I would need to create is a DAX measure that skips (not hides) the blanks. Meaning, if there is no value in Lvl4, it should show Lvl5 instead.

So, for ID 1, I should have:
Costs

   Financial Expenses

      Fees

         Bank charges

 

and for ID 2 I should have:

Costs

   Other Expenses

      Other Services

         IT Services

            Security

 

I created the following DAX measure (below), but this only hides the rows where Lvl4 is blank, so the hierarchy ends at Lvl3, without displaying the Lvl5 values. 

 

Countrows Table =
SWITCH(TRUE(),
AND(ISINSCOPE(TABLE[Lvl1]), ISBLANK(VALUES(TABLE[Lvl1]))), BLANK(),
AND(ISINSCOPE(TABLE[Lvl2]), ISBLANK(VALUES(TABLE[Lvl2]))), BLANK(),
AND(ISINSCOPE(TABLE[Lvl3]), ISBLANK(VALUES(TABLE[Lvl3]))), BLANK(),
AND(ISINSCOPE(TABLE[Lvl4]), ISBLANK(VALUES(TABLE[Lvl4]))), BLANK(),
AND(ISINSCOPE(TABLE[Lvl5]), ISBLANK(VALUES(TABLE[Lvl5]))), BLANK(),
COUNTROWS(TABLE))
 
How can I adjust my measure or create a new one to get the desired result? 
 
Thanks!
2 REPLIES 2
Anonymous
Not applicable

Hey un97, have you tried something like this?

 

CountRowsTable =
VAR SelectedLvl4 = VALUES(TABLE[Lvl4])
VAR SelectedLvl5 = VALUES(TABLE[Lvl5])
VAR Count = COUNTROWS(TABLE)
RETURN
SWITCH(
TRUE(),
ISINSCOPE(TABLE[Lvl5]) && ISBLANK(SelectedLvl4), CONCATENATEX(SelectedLvl5, TABLE[Lvl5], " > "),
ISINSCOPE(TABLE[Lvl4]) && ISBLANK(SelectedLvl5), CONCATENATEX(SelectedLvl4, TABLE[Lvl4], " > "),
ISINSCOPE(TABLE[Lvl3]), CONCATENATEX(VALUES(TABLE[Lvl3]), TABLE[Lvl3], " > "),
ISINSCOPE(TABLE[Lvl2]), CONCATENATEX(VALUES(TABLE[Lvl2]), TABLE[Lvl2], " > "),
ISINSCOPE(TABLE[Lvl1]), CONCATENATEX(VALUES(TABLE[Lvl1]), TABLE[Lvl1], " > "),
BLANK()
) & Count

Hi devindupree01, unfortunately this measure didn't work. 

 

The result I got with the measure you provided is this:

Screenshot 2023-07-16 201051.png

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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