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
bistabil
Regular Visitor

Optimizing hierarchy sum column

I need to calculate sum of integer value for all child elements in the hierarchy.

 

The solution posted here, https://community.powerbi.com/t5/Desktop/Summing-Aggregating-on-Parent-Child-Hierarchies/m-p/394500#..., solves my issue but it's painfully slow and only sometimes works. Other times it just loads indefinetly or throws out of memory exception.

 

The measure I'm using is:

Measure = 
VAR c = 
    SELECTEDVALUE(DimWorkItemCurrent[SystemID]) 
RETURN 
    CALCULATE(
        SUM(FactWorkItemScheduling[Hours]); 
        ALLSELECTED(DimWorkItemCurrent[SystemID]); 
        PATHCONTAINS(DimWorkItemCurrent[PBI_WorkItemPath]; c)
    )

 

Even when I narrow down the slicers to only 100 rows it doesn't speed up so I presume the measure still does the calculation across the whole fact table, instead of across filtered rows.

I guess the ALLSELECTED part is not doing what I'm hoping it would do?

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@bistabil 

 

You may take a look at links below.

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.