cancel
Showing results 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.

Helper IV

## Sum and display columns based on slicer

I work at a high school using a hybrid schedule. Some students in on A days and others in on B days. Some parents want their kids at school everyday (A-S, B-S designations on their record) I need to figure out how many A hybrid and B student kids are in each class to see if we have enough safe room for all in the classroom or if we need to have some students watching the class on Zoom from somewhere else in the building.

Trying to have A-H # and B-S # show and sum when A is selected on the Group slicer and the same for B-H# and A-S# when Group B is selected.

Currently both A's show up when group A is selected and same for B because I originally created new columns using "Group" & "Attend"

2 ACCEPTED SOLUTIONS
Helper IV

@tex628 Awesome. Thanks for your help!

Community Support

Hi @jrmaier ,

You can also create a slicer table:

Then use the following measure in your matrix:

``````measure =
SWITCH (
SELECTEDVALUE ( 'Table2'[slicer] ),
"A",
IF (
HASONEVALUE ( 'Data'[Code] ),
IF (
MAX ( 'Data'[Code] ) IN { "A-H", "B-S" },
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block] ),
'Data'[Code] = MAX ( 'Data'[Code] )
)
),
BLANK ()
),
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block] ),
'Data'[Code] IN { "A-H", "B-S" }
)
)
),
"B",
IF (
HASONEVALUE ( 'Data'[Code] ),
IF (
MAX ( 'Data'[Code] ) IN { "A-S", "B-H" },
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block] ),
'Data'[Code] = MAX ( 'Data'[Code] )
)
),
BLANK ()
),
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block]),
'Data'[Code] IN { "A-S", "B-H" }
)
)
),
"C",
IF (
MAX ( 'Data'[Code] ) = "C-R",
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block]),
'Data'[Code] = MAX ( 'Data'[Code] )
)
),
BLANK ()
)``````

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EcbBOLH1ufxFtl5jNF...

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,

Dedmon Dai

23 REPLIES 23
Community Champion

The table there is created through the "Enter data" fuctionality, you can edit it directly in power query to match your requirement:

Just make sure that the codes in the "Code" column correspond to the correct codes in the main table.

/ J

Helper IV

@tex628 Awesome. Thanks for your help!

Community Support

Hi @jrmaier ,

You can also create a slicer table:

Then use the following measure in your matrix:

``````measure =
SWITCH (
SELECTEDVALUE ( 'Table2'[slicer] ),
"A",
IF (
HASONEVALUE ( 'Data'[Code] ),
IF (
MAX ( 'Data'[Code] ) IN { "A-H", "B-S" },
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block] ),
'Data'[Code] = MAX ( 'Data'[Code] )
)
),
BLANK ()
),
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block] ),
'Data'[Code] IN { "A-H", "B-S" }
)
)
),
"B",
IF (
HASONEVALUE ( 'Data'[Code] ),
IF (
MAX ( 'Data'[Code] ) IN { "A-S", "B-H" },
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block] ),
'Data'[Code] = MAX ( 'Data'[Code] )
)
),
BLANK ()
),
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block]),
'Data'[Code] IN { "A-S", "B-H" }
)
)
),
"C",
IF (
MAX ( 'Data'[Code] ) = "C-R",
CALCULATE (
COUNT ( 'Data'[User ID] ),
FILTER (
ALLEXCEPT ( 'Data', 'Data'[Room Number], 'Data'[Course Title], 'Data'[Block]),
'Data'[Code] = MAX ( 'Data'[Code] )
)
),
BLANK ()
)``````

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EcbBOLH1ufxFtl5jNF...

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,

Dedmon Dai

Announcements

#### 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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors