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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Calculating measures based on different hierarchy levels

Hi All,

 

I need to know how to perform calculations on different levels of a hierarchy. 

 

Take this matrix as an example;

 

 

Matrix-hierarchies.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Say the Customer Service is Level2 of the hierarchy. (Level 1 being client)

 

The STDEVP.1_Duration is the Standard deviation measure on the duration column. So as per the image above I need to add a new column beside it where it takes the Duration and subtracts the STDEVP.1_duration of the parent level. So in the example above for Customer Service, Total = 22194891 - 406 = 22194485.

 

How do we perform calculations on different levels of the hierarchy?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

So I managed to solve this using this DAX:

 

IF (
  ISFILTERED ( AgentTable[EmployeeID] ),
  CALCULATE([STDEVP.1_Duration],ALL(AgentTable[EmployeeID])) - SUM(Duration),
     IF (
        ISFILTERED ( AgentTable[TeamID] ),
        CALCULATE([STDEVP.1_Duration],ALL(AgentTable[TeamID]))- SUM(Duration),
             IF (
                 ISFILTERED ( AgentTable[DeptID] ),
                 CALCULATE([STDEVP.1_Duration],ALL(AgentTable[DeptID]))- SUM(Duration),
                     IF (
                        ISFILTERED ( AgentTable[ClientID]),
                        CALCULATE([STDEVP.1_Duration],ALL(AgentTable[ClientID]))- SUM(Duration)

        )
    )
)

View solution in original post

3 REPLIES 3
theov
Helper IV
Helper IV

Basically we use ISFILTERED for such requirements. However, sometimes your total line might be wrong or empty, in that case you can add HASONEFILTER to detect total line and calculate it differently
Also you might need to have different number formats for each level, in that case you can add FORMAT function. Yet because it is a text function you might have empty lines, so you need to add ISBLANK.

 

This video explains fully the production based on hierarchy level with example 🙂

https://www.youtube.com/watch?v=LV9LqcEmgFc

Anonymous
Not applicable

So I managed to solve this using this DAX:

 

IF (
  ISFILTERED ( AgentTable[EmployeeID] ),
  CALCULATE([STDEVP.1_Duration],ALL(AgentTable[EmployeeID])) - SUM(Duration),
     IF (
        ISFILTERED ( AgentTable[TeamID] ),
        CALCULATE([STDEVP.1_Duration],ALL(AgentTable[TeamID]))- SUM(Duration),
             IF (
                 ISFILTERED ( AgentTable[DeptID] ),
                 CALCULATE([STDEVP.1_Duration],ALL(AgentTable[DeptID]))- SUM(Duration),
                     IF (
                        ISFILTERED ( AgentTable[ClientID]),
                        CALCULATE([STDEVP.1_Duration],ALL(AgentTable[ClientID]))- SUM(Duration)

        )
    )
)
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous ,

It is hard to reporduce your data structure, could you please post a simple sample to have a test for your problem?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
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!

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