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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
BekahLoSurdo
Resolver IV
Resolver IV

Adjusting Multiple Visuals with One Slicer

Hello,

 

I am trying to create a scorecard that shows a comparison between:

a) An employee's breakdown of hours by type of work

b) Breakdown of hours by type of work for that employee's entire division 

- if they do work for more than one division, this should show the type-of-work makeup for the cumulative hours of all applicable divisions

c) Breakdown of hours by type of work for the company as a whole

 

Here is some sample data / desired visual:

 

PersonDivisionProject TypeHours
A1Electrical100
A1Software200
A1Mechanical400
A1Technical60
B1Electrical500
B1Software200
B2Mechanical300
B2Technical800
B3Technical600
C2Electrical100
C2Software200
C2Mechanical400
C1Mechanical60
C2Technical500
D3Electrical200
D3Software300
D2Mechanical800
D2Technical

600

Sample Visual.PNG

I am able to easily present a) and c) but I am having trouble getting the slicer for a) to affect the visualization for b).

 

Switching my "Person" slicer around adds the appropriate options to my "Division" slicer (not shown above as it will be hidden in the final report) but it does not auto-check them which is what I need. For instance, switching from A to C results in:

Sample Visual 2.PNG

Thank you in advance for any help!

1 ACCEPTED SOLUTION

Oh, I see, so the current expression only get the divisions that exist for a given customer for a given type. So when you filter by B, it excludes division 1 from the type Technical as customer B does not have that combination.

 

The following code should fix this by getting all divisions for the current context, regardless of type and then passing that in when calculating the hours.

 

Hours by Division = 
Var _divisions = CALCULATETABLE( values(Table1[Division]), all(Table1[Project Type]))
var _types = VALUES(Table1[Project Type])
return CALCULATE(sum(Table1[Hours]), ALL(Table1),_types,_divisions)

View solution in original post

4 REPLIES 4
d_gosbell
Super User
Super User

I'm assuming that you have 3 separate measure here to calculate the results for the different doughnut charts. For the middle chart I would use an expression like the following:

 

Hours by Division = CALCULATE(sum(Table1[Hours]), ALL(Table1),VALUES(Table1[Division]))

Hi @d_gosbell,

 

This is close but doesn't take into the account the fact that I need to include Project Type in the context as well or the following occurs:

 

Solution.PNG

I'm new to DAX so this may not be the best way to add to the context but going off of your code I changed it to:

Hours by Division = CALCULATE(SUM(Sheet1[Hours]), ALL(Sheet1), VALUES(Sheet1[Division]), VALUES(Sheet1[Project Type]))

This fixed the problem with the pre-filtered visual:

Solution2.PNG

 

But now, because the measure is taking into account Division + Project Type, when I filter by (for instance) Person B, the visual is only showing the cominbations of Division + Project Type that Person B has:

 

Solution3.PNG

Instead of this, what I need is: since Person B is in all 3 divisions, this should show the total of all Divisions (regardless of Project Type).

 

How do I include the granularity of Project Type for the sake of the legend but ignore it for the sake of the totals?

 

Thank you!

Oh, I see, so the current expression only get the divisions that exist for a given customer for a given type. So when you filter by B, it excludes division 1 from the type Technical as customer B does not have that combination.

 

The following code should fix this by getting all divisions for the current context, regardless of type and then passing that in when calculating the hours.

 

Hours by Division = 
Var _divisions = CALCULATETABLE( values(Table1[Division]), all(Table1[Project Type]))
var _types = VALUES(Table1[Project Type])
return CALCULATE(sum(Table1[Hours]), ALL(Table1),_types,_divisions)

@d_gosbell, yes that was exactly the issue and yes, that is the perfect solution. I was thinking that I had to create an intermediary table but doing so via a variable is so much more elegant and efficient. Thank you so much!

 

Here are the final results for the first 3 employees:

Final.png

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.