cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Badger43
Frequent Visitor

DAX SUMX Multiple Hierarchy Level Query

Hi I am trying to return values from a 'Rates' table linked to the below 'MU' table on the Parent dimension (one MU to Many Rates)

 

I am using the formula SUMXVALUES MU[Parent] ) ,[Allocation %]) where Allocation% is a sum of the 'Rates' table values.

 

Badger43_1-1679678688090.png

This works fine, however, in some instances there will not be a value for MU([Parent]) in the 'Rates' table.  In this instance I would like to return the values linked to the 'Dept' column instead (which will neccessitate a many to many inactive relationship).

 

I am unable to successfully write a measure which substitues this 'Dept' link and then still consolidates the values correctly at total level.

 

I have tried something such as the below where I try and check whether the value exists and then substitute if not, and this works for individual rows but the totals are incorrect.

 

Have been stuck almost a full day on this, any help you can offer would be greatly appreciated.  Thanks in advance.

 

VAR hasvalue=CALCULATE([Allocation %],ALL(Rates[Stage],Rates[TA],Rates[Project Code]))

VAR dcode=
        CALCULATE([Allocation %],USERELATIONSHIP(MU[Dept],Rates[MU Code]),CROSSFILTER(MU[Parent],Rates[MU Code],None))
 
VAR pcode=
        [Allocation %]
RETURN
    SUMX(VALUES(MU[Parent]),if(hasvalue=0,dcode,pcode))

 

 

Link to demo file....https://drive.google.com/file/d/18PllpMYNDgzm3ck9pThhFGrCkZu78bmi/view?usp=sharing 

3 REPLIES 3
Badger43
Frequent Visitor

@lbendlin thanks very much for your reply and sorry I wasn't clearer.  I was anonymising and simplifying the full model and only got so far in the time I had.  I have reloaded the file with full renaming, and also update the formulas in my original post to take account of this.

 

In the MU 'Parent' column there are no gaps, but in some instances (for the RBU2 Series of the rates table) there is no corresponding value in the rates table.  At this point I would like it to use the values which would be linked on the MU'Dept' column instead.

 

Hope this makes things clearer and again a solution for this would be much appreciated.

 

Thanks again

Mark

In the MU 'Parent' column there are no gaps, but in some instances (for the RBU2 Series of the rates table) there is no corresponding value in the rates table. 

You lost me. I cannot see where the gaps are.

lbendlin
Super User
Super User

There is no Rates table in your sample data, and I don't see any gaps in the Parent column.  Please clarify.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors