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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Bacou
Frequent Visitor

DAX measure to calculate parent total from child while filtering

Hi ,

 

I have two tables:
one with a parent-child hierarchy 

 

Capture.PNG

 

and another containing the data

Data.PNG

 

I created a measure to calculate  the total on each parent : 

Mesure = var c = IF(HASONEVALUE(Hierachie[IdLigne]);VALUES(Hierachie[IdLigne]);BLANK()) RETURN CALCULATE (
sum('Fact'[Amount]);
ALL('Fact');
PATHCONTAINS (Hierachie[HierarchiePath]; c )
)

Capture.PNG

It works fine but i can't use the slicers (Area and Region) , normal because i use "All" in measure.

What I would like to be able to filter and always show all the codes even if I do not have amount.

 

For Example i select "Area : A0001" and "Region : R001" i would like to have this result :

 

Code  |  Amount 

10      | 102

20      |  0

30      |  102

40      |  12048

50      | 0

60      |  12048

70      | 0

80      | 12150

 

Thank you for your help .

 

Regards

 

 

1 ACCEPTED SOLUTION

Whoops, my mistake, I didn't read close enough. You can try create a measure along the lines of:

 

Measure = 
VAR __amount = SUM(Table[Amount])
RETURN
IF(ISBLANK(__amount),0,__amount)

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

Try ALLSELECTED instead of ALL?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg_Deckler,
thank you for your help i try ALLSELECTED but i don't have all the codes .
Regards

Whoops, my mistake, I didn't read close enough. You can try create a measure along the lines of:

 

Measure = 
VAR __amount = SUM(Table[Amount])
RETURN
IF(ISBLANK(__amount),0,__amount)

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

I have the same problem as Bacou, but couldn't understand what your solution means.

 

I'm studying DAX as beginner, and will be appreciated if you can provide actual code based on Becou's problem. I'll apply it with my case.

 

Thank you.

 

Pat.

Thank you it works.
Regards

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.