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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Calculate Quantity based on hierarchy to add in a matrix visual

Hi All,

 

I am looking to add a measure that calculates quantity count based on scenario below.

 1. Think of below as a row data. 

1.PNG

2. Think of below as a hierarchy when put on a matrix visual

2.PNG

 

So now I want to calculate quanitty as below.

learningPbidev_0-1648831327856.png

- Root appears (topmost item in the hierarchy) once in row data so qty for same is 1

- Assembly is a child of root and appears twice in the row data, it can be termed as root has two children, both named assembly so qty for that is calcualted as 2. 

- Now, Part A appears to be used only once in each assembly so qty for same is 1. 

- part B however is used twice in each assembly, so qty for same is 2. 

 

Can someone please help me with the formula for measure on this, I would really appreciate it, thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

Did you mean to use different rates based on current hierarchy levels?
If that's the case, you can take a look at the following link to know how to use 'if statement' to check current hierarchy levels. (you can use it to dynamic replace the result rates based on the current category )

Clever Hierarchy Handling in DAX - SQLBI

In addition, you can also check the below link about selectedvalue and switch functions if helps:

My Favorite DAX Feature: SELECTEDVALUE with SWITCH | Winston-Salem Power BI User Group (pbiusergroup.com)

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous,

Did you mean to use different rates based on current hierarchy levels?
If that's the case, you can take a look at the following link to know how to use 'if statement' to check current hierarchy levels. (you can use it to dynamic replace the result rates based on the current category )

Clever Hierarchy Handling in DAX - SQLBI

In addition, you can also check the below link about selectedvalue and switch functions if helps:

My Favorite DAX Feature: SELECTEDVALUE with SWITCH | Winston-Salem Power BI User Group (pbiusergroup.com)

Regards,

Xiaoxin Sheng

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