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
Anonymous
Not applicable

CALCULATE FILTER CONTEXT

I'm trying to create two measures and these are the formulas in human language that I'm using:

- Share corp = sales filtered/sales company
- Share div = sales dept/sales div


I have three filters:

Dir
Div
Dept

 

These are the tables:

 

SalesTable
salesdirdivdept
99ADiv1dept1
21ADiv1dept2
74ADiv2dept3
48ADiv2dept3
54BDiv3dept4
18BDiv4dept5
1CDiv5dept6
65CDiv5dept6
16CDiv5dept7
30CDiv5dept7

 

StructureTable
dirdivdept
Adiv1dept1
Adiv1dept2
Adiv2dept3
Bdiv3dept4
Bdiv4dept5
Cdiv5dept6
Cdiv5dept7


Is there a way to get "share div" WITHOUT having to filter a dept_nbr in the slicer before? Because now, to get that, the only way I figured to make it work is by first filtering a div, and then filter a dept. If I filter the dept only, without filtering the division first, I get the "share corp" result instead of the "share div" one.


In short words, I need DAX to understand that when I select a dept, he has to divide total sales of that dept by total sales of the div that this dept belongs to, without having to filter the div in the silcer before.

 

Thank you all in advance.

3 REPLIES 3
wdx223_Daniel
Super User
Super User

does this work?

Share Div = DIVIDE(SUM(SalesTable[sales]),CALCULATE(SUM('SalesTable'[sales]),ALL('StructureTable'[dept])))
lbendlin
Super User
Super User

Please explain why you repeat the structure in the Sales table.  The Sales table should only contain the dept and sales columns.

Anonymous
Not applicable

Hi @lbendlin, thank you for your time.

 

That's a good point. If we modify it, the measure I'm asking for, would be possible to ahieve?

 

Thanks again.

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.

Top Solution Authors