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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
mjcuccia
Frequent Visitor

hierarchy row counts

I have a need to get the row count for a particular level in my hierarchy to use that value in each child row of that hierarchy level.

 

In the example below, I would want the number of rows under the hierarchy level of 2017/Region: East/Location: Grove/Site: Grove.  Obviously, that count is 7.  I have struggled to get to that number since each of the OEM's under each site show up under multiple sites.  I have been getting an aggregate number including all rows which contain 'Lockheed Martin', for example.  In this case, I should only have a count of 1 for Lockheed Marting under this hierarchy level with the total aggregate of 7, and then I can use that count of 7 in a DAX formula for every row under this hierarchy level.  I would also need to use this type of row count for every iteration of this hierarchy level in the table at the OEM level under site.  Hope that makes sense!

 

HierarchyRowCount.png

 

 

1 ACCEPTED SOLUTION

cant test to guarantee , but you can try something like this

 

hier-count = 
CALCULATE( DISTINCTCOUNT( mytable[id] )
                            ,ALLEXCEPT(myTable ,
                               myTable[Grove])
             )

hope this is understandable 🙂 

View solution in original post

4 REPLIES 4
Nickgastaldi
Resolver I
Resolver I

@mjcuccia

can you elaborate a little? 

 

the table you show is what you have or what you want? 

this calculations will be done in this table or are you building new measures for this ? 

 

help me understand, 

in your table, 

Site:Grove has OEM RANK = 1 

 but it should be 7 

is that your problem? 

You can ignore OEM rank for the level at which Grove sits.  That rank only applies to the actaul OEM's which are under Grove.

 

I simply need on each row under Grove to acquire the row count of distinct OEM's only under Grove (this formula would be used for all other sites in the hierarchy as well), but in the example pic just Grove for now).  The count of distinct rows for Grove should come out to 7 to be used in a DAX formula on each row under Grove.

cant test to guarantee , but you can try something like this

 

hier-count = 
CALCULATE( DISTINCTCOUNT( mytable[id] )
                            ,ALLEXCEPT(myTable ,
                               myTable[Grove])
             )

hope this is understandable 🙂 

Crushed it!  Thanks Nickgastaldi!  Answer was like this:

 

hier-count = 
CALCULATE( DISTINCTCOUNT( mytable[OEM] )
                            ,ALLEXCEPT(myTable ,
                               myTable[Site])
             )

Helpful resources

Announcements
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.