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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
iLoveTea
Frequent Visitor

Hide blank values in hierarchy matrix

Hello everyone,

I've been browsing past threads about hiding blank values in matrix with hierarchical data but i think i have a bug in doing so.

After i flag all blank lines, when i try to filter them out, all the values dissapear.
I have no idea why.
Here's an image showing the issue.

MicrosoftTeams-image (1).png

1 ACCEPTED SOLUTION

Hi , @iLoveTea 

According to your image, we can not make this measure return 1 and 0 and then filter it.

I test this method before,it dose not work the same as yours.

The method should return the value you need, you need to update this measure return teh value which this column need.And you need to replace all the column by the measures.

vyueyunzhmsft_0-1668648597668.png

That means you need to create two measures like that to replace this two yellow columns.You need to replace the 1 to your need value in the measure .

 

Best Regards,

Aniya Zhang

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

11 REPLIES 11
HalloWorld
Advocate II
Advocate II

This works if you aggregate, like the sum over the value column, so that you get one line from it. But what should I do if I needed to show all filled nodes' levels in a hierarchy on the left, and on the right the nodes' names? I need one name in each row where the level is filled. One way is to put an id as another item in the hierarchy on the left. But then, the formula will not work anymore. If the level is not filled, it should not be shown, yet, the empty nodes are shown nevertheless.

I picked some screenshots and try to make it clearer what happens here.

 

Here in the example, I took numerical IDs instead of names, though:

HalloWorld_1-1731664511495.png

I took the number of children as the hierarchy instead of the things in the accepted answer's example.

The measure in the right column is:

```

replace id (measure) = IF( ISINSCOPE(myTbl[number_of_children])&& SELECTEDVALUE(myTbl[number_of_children])=BLANK(),BLANK(),IF(ISINSCOPE(myTbl[number_of_children_1])&& SELECTEDVALUE(myTbl[number_of_children_1])=BLANK(),BLANK(),IF(ISINSCOPE(myTbl[number_of_children_2])&&SELECTEDVALUE(myTbl[number_of_children_2])=BLANK(),BLANK(),IF(ISINSCOPE(myTbl[number_of_children_3])&& SELECTEDVALUE(myTbl[number_of_children_3])=BLANK(),BLANK(),IF(ISINSCOPE(myTbl[number_of_children_4])&& SELECTEDVALUE(myTbl[number_of_children_4])=BLANK(),BLANK(),IF(ISINSCOPE(myTbl[number_of_children_5])&& SELECTEDVALUE(myTbl[number_of_children_5])=BLANK(),BLANK(),IF(ISINSCOPE(myTbl[number_of_children_6])&& SELECTEDVALUE(myTbl[number_of_children_6])=BLANK(),BLANK(),IF(ISINSCOPE(myTbl[number_of_children_7])&& SELECTEDVALUE(myTbl[number_of_children_7])=BLANK(),BLANK(),IF(ISINSCOPE(myTbl[number_of_children_8])&& SELECTEDVALUE(myTbl[number_of_children_8])=BLANK(),BLANK(),IF(ISINSCOPE(myTbl[number_of_children_9])&& SELECTEDVALUE(myTbl[number_of_children_9])=BLANK(),BLANK(),MAX(myTbl[id])))))))))))

```

I need *one* name in *each* row where the level is filled since each node has a name that I want to show, and on the left, I will take the level numbers or number of children as the hierarchy (or I will change to something else like the names in the hierarchy later; but I want names in other languages listed in the columns). One way is to put an id as another item in the hierarchy on the left so that MAX() does not aggregate anything, every row is spread by the identifier, and this will show the ids in the leaves:

HalloWorld_0-1731663959325.png

The formula in the accepted answer might work well. I did not check it and trust its screenshots that show clearly that it works. But in my setting, if I check each level for `= BLANK(), BLANK(), else MAX()`, as in the accepted answer, every blank level that is found in that formula drops its whole branch:

HalloWorld_2-1731665912073.png

Thus, if I write the formula shorter, just for level 0 to 4, nodes that have *only* such filled levels will show up:

HalloWorld_3-1731666994445.png

And if I now check for level 5 to be BLANK(), all of the branches that do not have level 5 are dropped, which means in my data that just four branches are left. This does not show any empty nodes, but it also just filters for all that have *only* five levels. The rest is dropped. I see that in the accepted answer, it works better, there you have a depth of two and four, and the one of depth two does not have a [+] sign so that the last level is really shown without any empty levels coming after it. I can tweak a nice graph here if I just choose 5 out of 9 levels. You would think at first sight, that it works:

 

HalloWorld_4-1731668504523.png

But that is only a bad trick here. I want to show all branches of any length, not just those of length 5.

 

If a level is not filled (if the level is not in the data at all), it should not be shown. Yet, the empty nodes *are* shown. The measure works "a bit" like in the answer, but not in full: if I put the new measure with just four levels in the matrix values, the tree gets reduced automatically to the filled levels for some, but for the most, some empty levels are still shown. And as soon as I ask to drill down all nodes to their leaves, all of the empty levels are shown again, and I cannot get rid of them anymore without starting from new by taking out the measure and putting it in again. In the accepted answer's image, I can see that the tree really stops at the leaf level without showing a [+] box that you still could click to see the empty levels below it. But when I do this, the tree gets reduced to the filled levels, and the [+] box is shown:

HalloWorld_5-1731669228663.png

And I can drill down to:

HalloWorld_6-1731669250369.png

The empty boxes are shown again, and you cannot get rid of them easily unless you return to PBI and put the measure out and in again.

I found it. You need to switch on the row totals of the matrix. I only understood that this would fix it when I rebuilt the example of the accepted answer. Without the row totals, you get less nodes, the master1 node is missing. This is since the formula drops any path that has a blank in the first four levels:

 

HalloWorld_0-1731709692956.png

 

And with row totals, you get the needed rows for the master1 branch as well:

 

HalloWorld_1-1731709839118.png

This fixes it also in the hierarchy model of my own data.

 

 

 

And then it also worked with my data. I flatten the data already in SSIS, if you do not want that, you can flatten it in Power BI and need one "step 0" more, see the first link.

 

Links:

Parent-child hierarchies – DAX Patterns

Solved: Hide blank values in hierarchy matrix - Microsoft Fabric Community

 

1.

```

VV1Depth = (VV[Ebene] <> BLANK())+1 + (VV[Ebene_1] <> BLANK()) + (VV[Ebene_2] <> BLANK()) + (VV[Ebene_3] <> BLANK()) + (VV[Ebene_4]  <> BLANK()) + (VV[Ebene_5] <> BLANK()) + (VV[Ebene_6] <> BLANK()) + (VV[Ebene_7] <> BLANK()) + (VV[Ebene_8] <> BLANK()) + (VV[Ebene_9] <> BLANK())
```
2.
```
VV2RowDepth =
MAX ( VV[VV1Depth] )
```
3.
```
VV3BrowseDepth =
    ISINSCOPE ( VV[Anzahl_Kinder] )
    + ISINSCOPE ( VV[Anzahl_Kinder_1] )
    + ISINSCOPE ( VV[Anzahl_Kinder_2] )
    + ISINSCOPE ( VV[Anzahl_Kinder_3] )
    + ISINSCOPE ( VV[Anzahl_Kinder_4] )
    + ISINSCOPE ( VV[Anzahl_Kinder_5] )
    + ISINSCOPE ( VV[Anzahl_Kinder_6] )
    + ISINSCOPE ( VV[Anzahl_Kinder_7] )
    + ISINSCOPE ( VV[Anzahl_Kinder_8] )
    + ISINSCOPE ( VV[Anzahl_Kinder_9] )
```

 

4. (Example)

 

This shows the number of Children inside a root tree for each node if in the hierarchy, there are always two nodes for each level, first the name and then the number of children, nested right after each other, so that there are 9x2 nodes in the hierarchy:

 

```

MyTblNumberOfChildren =
VAR CurrentNode =
    SELECTEDVALUE(MyTbl[Name]) // This should pick the current node in the context
VAR AssociatedChildrenCount =
    CALCULATE(
        COUNTROWS(MyTbl),
        FILTER(MyTbl, MyTbl[Name] = CurrentNode)
    )
VAR EntityShowRow =
    [MyTbl3BrowseDepth] <= [MyTbl2RowDepth]
VAR Result =
    IF ( EntityShowRow, IF ( ISINSCOPE(MyTbl[Name]) && SELECTEDVALUE(MyTbl[Name]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children]) && NOT(ISINSCOPE(MyTbl[Name_1])), BLANK(), IF ( ISINSCOPE(MyTbl[Name_1]) && SELECTEDVALUE(MyTbl[Name_1]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children_1]) && NOT(ISINSCOPE(MyTbl[Name_2])), BLANK(), IF ( ISINSCOPE(MyTbl[Name_2]) && SELECTEDVALUE(MyTbl[Name_2]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children_2]) && NOT(ISINSCOPE(MyTbl[Name_3])), BLANK(), IF ( ISINSCOPE(MyTbl[Name_3]) && SELECTEDVALUE(MyTbl[Name_3]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children_3]) && NOT(ISINSCOPE(MyTbl[Name_4])), BLANK(), IF ( ISINSCOPE(MyTbl[Name_4]) && SELECTEDVALUE(MyTbl[Name_4]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children_4]) && NOT(ISINSCOPE(MyTbl[Name_5])), BLANK(), IF ( ISINSCOPE(MyTbl[Name_5]) && SELECTEDVALUE(MyTbl[Name_5]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children_5]) && NOT(ISINSCOPE(MyTbl[Name_6])), BLANK(), IF ( ISINSCOPE(MyTbl[Name_6]) && SELECTEDVALUE(MyTbl[Name_6]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children_6]) && NOT(ISINSCOPE(MyTbl[Name_7])), BLANK(), IF ( ISINSCOPE(MyTbl[Name_7]) && SELECTEDVALUE(MyTbl[Name_7]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children_7]) && NOT(ISINSCOPE(MyTbl[Name_8])), BLANK(), IF ( ISINSCOPE(MyTbl[Name_8]) && SELECTEDVALUE(MyTbl[Name_8]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children_8]) && NOT(ISINSCOPE(MyTbl[Name_9])), BLANK(), IF ( ISINSCOPE(MyTbl[Name_9]) && SELECTEDVALUE(MyTbl[Name_9]) = BLANK() || ISINSCOPE(MyTbl[Number_of_children_9]), BLANK(), AssociatedChildrenCount )))))))))))
RETURN
    Result
```
 
PS: If you happen to run into a matrix that shows only one chosen level at a time, you need to add intermediate row sums to the matrix, that will show the rest that are not leaves as aggregated nodes in bold letters. It will be the MAX() but does not aggregate.
 
HalloWorld_0-1732562571185.png

 

4. (Further examples)

 

This shows an English name for a German name but does not show its empty nodes: 
 
```
VVEnglisch =
VAR Val = IF ( ISINSCOPE(VV[Bezeichnung_9]), MAX('VV'[Bezeichnung Englisch_9]), IF ( ISINSCOPE(VV[Bezeichnung_8]), MAX('VV'[Bezeichnung Englisch_8]), IF ( ISINSCOPE(VV[Bezeichnung_7]), MAX('VV'[Bezeichnung Englisch_7]), IF ( ISINSCOPE(VV[Bezeichnung_6]), MAX('VV'[Bezeichnung Englisch_6]), IF ( ISINSCOPE(VV[Bezeichnung_5]), MAX('VV'[Bezeichnung Englisch_5]), IF ( ISINSCOPE(VV[Bezeichnung_4]), MAX('VV'[Bezeichnung Englisch_4]), IF ( ISINSCOPE(VV[Bezeichnung_3]), MAX('VV'[Bezeichnung Englisch_3]), IF ( ISINSCOPE(VV[Bezeichnung_2]), MAX('VV'[Bezeichnung Englisch_2]), IF ( ISINSCOPE(VV[Bezeichnung_1]), MAX('VV'[Bezeichnung Englisch_1]), IF ( ISINSCOPE(VV[Bezeichnung]), MAX('VV'[Bezeichnung Englisch]), BLANK()))))))))))
VAR EntityShowRow =
    [VV3BrowseDepth] <= [VV2RowDepth]
VAR Result =
    IF ( EntityShowRow, IF ( ISINSCOPE(VV[Bezeichnung]) && SELECTEDVALUE(VV[Bezeichnung]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_1]) && SELECTEDVALUE(VV[Bezeichnung_1]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_2]) && SELECTEDVALUE(VV[Bezeichnung_2]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_3]) && SELECTEDVALUE(VV[Bezeichnung_3]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_4]) && SELECTEDVALUE(VV[Bezeichnung_4]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_5]) && SELECTEDVALUE(VV[Bezeichnung_5]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_6]) && SELECTEDVALUE(VV[Bezeichnung_6]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_7]) && SELECTEDVALUE(VV[Bezeichnung_7]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_8]) && SELECTEDVALUE(VV[Bezeichnung_8]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_9]) && SELECTEDVALUE(VV[Bezeichnung_9]) = BLANK(), BLANK(), Val )))))))))))
RETURN
    Result
```
 
This concatenates the whole path from root to leaf:
```
VVEnglischPath =
VAR Val = COMBINEVALUES("|", MAX('VV'[Bezeichnung Englisch]), IF ( ISINSCOPE(VV[Bezeichnung_1]), MAX('VV'[Bezeichnung Englisch_1]), BLANK()), IF ( ISINSCOPE(VV[Bezeichnung_2]), MAX('VV'[Bezeichnung Englisch_2]), BLANK()), IF ( ISINSCOPE(VV[Bezeichnung_3]), MAX('VV'[Bezeichnung Englisch_3]), BLANK()), IF ( ISINSCOPE(VV[Bezeichnung_4]), MAX('VV'[Bezeichnung Englisch_4]), BLANK()), IF ( ISINSCOPE(VV[Bezeichnung_5]), MAX('VV'[Bezeichnung Englisch_5]), BLANK()), IF ( ISINSCOPE(VV[Bezeichnung_6]), MAX('VV'[Bezeichnung Englisch_6]), BLANK()), IF ( ISINSCOPE(VV[Bezeichnung_7]), MAX('VV'[Bezeichnung Englisch_7]), BLANK()), IF ( ISINSCOPE(VV[Bezeichnung_8]), MAX('VV'[Bezeichnung Englisch_8]), BLANK()), IF ( ISINSCOPE(VV[Bezeichnung_9]), MAX('VV'[Bezeichnung Englisch_9]), BLANK()))
VAR EntityShowRow =
    [VV3BrowseDepth] <= [VV2RowDepth]
VAR Result =
    IF ( EntityShowRow, IF ( ISINSCOPE(VV[Bezeichnung]) && SELECTEDVALUE(VV[Bezeichnung]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_1]) && SELECTEDVALUE(VV[Bezeichnung_1]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_2]) && SELECTEDVALUE(VV[Bezeichnung_2]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_3]) && SELECTEDVALUE(VV[Bezeichnung_3]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_4]) && SELECTEDVALUE(VV[Bezeichnung_4]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_5]) && SELECTEDVALUE(VV[Bezeichnung_5]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_6]) && SELECTEDVALUE(VV[Bezeichnung_6]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_7]) && SELECTEDVALUE(VV[Bezeichnung_7]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_8]) && SELECTEDVALUE(VV[Bezeichnung_8]) = BLANK(), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_9]) && SELECTEDVALUE(VV[Bezeichnung_9]) = BLANK(), BLANK(), Val )))))))))))
RETURN
    Result
```
 
This allows to put both "Bezeichnung" (name) and "Anzahl_Kinder" (number of children) in the matrix hierarchy and will not show any value in the hierarchy rows of any number of children:
 
```
VVEnglischPath_2nodesperlevel =
VAR Val = COMBINEVALUES("|", MAX('VV'[Bezeichnung Englisch]), IF ( ISINSCOPE(VV[Bezeichnung_1]), MAX('VV'[Bezeichnung Englisch_1]), BLANK()), ..., MAX('VV'[Bezeichnung Englisch_9]), BLANK()))
VAR EntityShowRow =
    [VV3BrowseDepth] <= [VV2RowDepth]
VAR Result =
    IF ( EntityShowRow, IF ( ISINSCOPE(VV[Bezeichnung]) && SELECTEDVALUE(VV[Bezeichnung]) = BLANK() || ISINSCOPE(VV[Anzahl_Kinder]) && NOT(ISINSCOPE(VV[Bezeichnung_1])), BLANK(), IF ( ISINSCOPE(VV[Bezeichnung_1]) && SELECTEDVALUE(VV[Bezeichnung_1]) = BLANK() || ISINSCOPE(VV[Anzahl_Kinder_1]) && NOT(ISINSCOPE(VV[Bezeichnung_2])), BLANK(), ... BLANK(), Val )))))))))))
RETURN
    Result
```
iLoveTea
Frequent Visitor

Hi @amitchandak @v-yueyunzh-msft 
I tried amitchandak but it didnt work
I tried yueyunzh but i dont have a value column to leverage.

here's what i have :

iLoveTea_0-1668603850981.png£
In field i have 9 categories.

The removeblank measure is : 

_Remove Blanks =

SWITCH(TRUE(),

AND(ISINSCOPE('cache Activite_Hiera'[test_tact_code_cat2]),ISBLANK(VALUES('cache Activite_Hiera'[test_tact_code_cat2]))),BLANK(),

AND(ISINSCOPE('cache Activite_Hiera'[test_tact_code_cat3]),ISBLANK(VALUES('cache Activite_Hiera'[test_tact_code_cat3]))),BLANK(),

AND(ISINSCOPE('cache Activite_Hiera'[test_tact_code_cat4]),ISBLANK(VALUES('cache Activite_Hiera'[test_tact_code_cat4]))),BLANK(),

AND(ISINSCOPE('cache Activite_Hiera'[test_tact_code_cat5]),ISBLANK(VALUES('cache Activite_Hiera'[test_tact_code_cat5]))),BLANK(),

AND(ISINSCOPE('cache Activite_Hiera'[test_tact_code_cat6]),ISBLANK(VALUES('cache Activite_Hiera'[test_tact_code_cat6]))),BLANK(),

AND(ISINSCOPE('cache Activite_Hiera'[test_tact_code_cat7]),ISBLANK(VALUES('cache Activite_Hiera'[test_tact_code_cat7]))),BLANK(),

AND(ISINSCOPE('cache Activite_Hiera'[test_tact_code_cat8]),ISBLANK(VALUES('cache Activite_Hiera'[test_tact_code_cat8]))),BLANK(),

AND(ISINSCOPE('cache Activite_Hiera'[test_tact_code_cat9]),ISBLANK(VALUES('cache Activite_Hiera'[test_tact_code_cat9]))),BLANK(),

1)


When i filter the blanks in the filter panel, that happens:

iLoveTea_1-1668603928739.png

 

What i would like to achieve is that 

iLoveTea_2-1668604205910.png

 


Thank you for your help 

Hi , @iLoveTea 

According to your image, we can not make this measure return 1 and 0 and then filter it.

I test this method before,it dose not work the same as yours.

The method should return the value you need, you need to update this measure return teh value which this column need.And you need to replace all the column by the measures.

vyueyunzhmsft_0-1668648597668.png

That means you need to create two measures like that to replace this two yellow columns.You need to replace the 1 to your need value in the measure .

 

Best Regards,

Aniya Zhang

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

 

v-yueyunzh-msft
Community Support
Community Support

Hi , @iLoveTea 

According to your description, you want to "Hide blank values in hierarchy matrix". Right?

Here is a method you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1668586162269.png

(2)We can create a measure to replace the value in your visual:

Replace sum of value = IF( ISINSCOPE('Table'[Type1])&& SELECTEDVALUE('Table'[Type1])=BLANK(),BLANK(),IF(ISINSCOPE('Table'[Type2])&& SELECTEDVALUE('Table'[Type2])=BLANK(),BLANK(),IF(ISINSCOPE('Table'[Type3])&&SELECTEDVALUE('Table'[Type3])=BLANK(),BLANK(),IF(ISINSCOPE('Table'[Type4])&& SELECTEDVALUE('Table'[Type4])=BLANK(),BLANK(),SUM('Table'[Value])))))

(3)Then we can put the field on the visual :

vyueyunzhmsft_1-1668586529266.png

 

Best Regards,

Aniya Zhang

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

 

@iLoveTea 

This can help but you can't export all rows. Could you please check and let me know, how can i achieve this.

Thanks

Hey, let's move one step forward to this problem. I was getting the same problem and had it solved with this measure. But now, when I export the data to excel some of the rows are filtering out. No, visual level filter is applied. Even when I convert the matrix to a table visual the values are getting filtered out. Any help will be appreciated.

amitchandak
Super User
Super User

@iLoveTea , in visual level filter check that level is not blank

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors