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
amarsale85
Helper II
Helper II

Parent child aggregation DAX code not working

Hi Experts,

 

I followed the link below to create my DAX code measure:

https://community.powerbi.com/t5/Desktop/Summing-Aggregating-on-Parent-Child-Hierarchies/m-p/394500#...

 

In the example given in link, the code will only work with "Company" attribute but if i add attributes from another dimensions say Location, SalesType, etc., this DAX code won't work. So what change i need to do in the DAX code for it work with attributes in dimensions?

 

Please help.

7 REPLIES 7
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @amarsale85 ,

 

can you provide some sample data?
Are you using your star scheme?

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


In the 1st post i had given all details of data which got lost as i got some error, same happened 2nd time. 3rd time i kept it short 

Anyways here is my data,

 

DimLocation

LocationIDLocationParent Location ID
1North AmericaNULL
2USA1
3Florida2
4Miami3
5Fort Myers3
6Canada1
7Ontario6
8Toronto7

 

DimAmountType

AmountTypeIDAmount Type
1Registration Fees
2License Fees
3Product Cost

 

FactAmount

FactKeyLocationIDAmountTypeIDAmount
1131000
221250
342150
452100
5631500
6731200
781300
882200

@amarsale85 , refer if these can help

https://radacad.com/parsing-organizational-hierarchy-or-chart-of-accounts-in-power-bi-with-parent-ch...

https://www.thebiccountant.com/2019/10/03/parent-child-hierarchies-with-multiple-parents-in-power-bi...

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

Thank you for the help but unfortunately this doesn't help me.

I should be able to show data in chart as shown below:

 

Capture.JPG

 Here you can see, All Locations selected are from different levels, but are seen besides each other, that is no drill down.

Anonymous
Not applicable

Hi @amarsale85 ,

First, please make sure those 3 tables have created relationships as below screen shot. Then create a stacked column chart (Axis: Location in table DimLocation, Legend: Account Type in DimAccountType and Values: Amount in table FactAmount ).

Create relationshipsCreate relationshipsCreate visualCreate visual

Best Regards

Rena

Thank you for taking time to answer by question. But it isn't the expected behavior.

In your Chart, you can see North America to have lower profit amount than Canada & Ontario, which is wrong because,

State/Province = Aggregation/Summation of amount of all its Children cities

Country = Aggregation/Summation of amount of all its Children States/Provinces

Continent = Aggregation/Summation of amount of all its Children countries

Anonymous
Not applicable

Hi @amarsale85 ,

I created a sample pbix file, please check if it is what you want.

1. Create a calculated column "Parent location" to get the name of parent location in table DimLocation

Parent location =
VAR a = 'DimLocation'[Parent Location ID]
RETURN
    IF (
        ISBLANK ( 'DimLocation'[Parent Location ID] ),
        'DimLocation'[Location],
        CALCULATE (
            MAX ( 'DimLocation'[Location] ),
            FILTER ( 'DimLocation', 'DimLocation'[LocationID] = a )
        )
    )

2. Create a stacked column chart (Axis: new calculated column Parent location   Legend: Amount Type in table DimAmountType   Values: Amount in table FactAmount)

Parent child aggregation DAX code not working_update.JPG

Best Regards

Rena

Helpful resources

Announcements
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 Kudoed Authors