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
Ncio
Helper II
Helper II

Measure slicer: sum when multiple selection?

Hello,

 

I've implemented a "measure slicer" that works well: using the slicer, I can select one mesure. 

 

I have a table with the values "filter1", "filter2", "filter3" that I use in a slicer.

And I use the following measure (simplified): 

Graph: Slicer Cumul annuel =
IF(HASONEFILTER('KPI: Slicer'[Type]),
SWITCH(SELECTEDVALUE('KPI: Slicer'[Type]),
"filter1", [KPI1],
"filter2", [KPI2],
"filter3", [KPI3],
),
BLANK()
)

 

==> Now, i'd like to be able to select multiple values in the slicer, and it would sum all selected mesures.

  • For instance, if I select "filter1" and "filter2" using the slicer, i'd like to have KPI1 + KPI2
  • Currently,
    • because of "HASONEFILTER", no calculations are done if I have more that one filter.
    • And "SELECTEDVALUE" works only if there is only one value.

Thank you,

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Ncio , try like

 

Graph: Slicer Cumul annuel =
calculate(

if(countx(filter('KPI: Slicer'[Type] , 'KPI: Slicer'[Type] = "filter1"),'KPI: Slicer'[Type] )+0 > 0, [KPI1],0)+
if(countx(filter('KPI: Slicer'[Type] , 'KPI: Slicer'[Type] = "filter2"),'KPI: Slicer'[Type] )+0 > 0, [KPI2],0)+
if(countx(filter('KPI: Slicer'[Type] , 'KPI: Slicer'[Type] = "filter3"),'KPI: Slicer'[Type] )+0 > 0, [KPI3],0)
)

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi, @Ncio 

Please check the below picture and the sample pbix file's link down below.

The left side chart is the single selection, and the right side chart is the multi-selection (Sum).

Once you multi-select the slicer, the left chart will go back to the default, and the right chart will sum the selected measures.

All measures are in the sample pbix file.

 

Picture2.png

 

https://www.dropbox.com/s/n1hwfr92e4ib8v9/diffaaa.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Assuming that all your measures return numbers you should be able to do something like

 

New Measure = sumx(values('measure slicer'[measure]),[Slicer Cumul annel])

 

This pattern might not perform very well as you add more visuals, measures or data to the report but should work.

 

 

 

amitchandak
Super User
Super User

@Ncio , try like

 

Graph: Slicer Cumul annuel =
calculate(

if(countx(filter('KPI: Slicer'[Type] , 'KPI: Slicer'[Type] = "filter1"),'KPI: Slicer'[Type] )+0 > 0, [KPI1],0)+
if(countx(filter('KPI: Slicer'[Type] , 'KPI: Slicer'[Type] = "filter2"),'KPI: Slicer'[Type] )+0 > 0, [KPI2],0)+
if(countx(filter('KPI: Slicer'[Type] , 'KPI: Slicer'[Type] = "filter3"),'KPI: Slicer'[Type] )+0 > 0, [KPI3],0)
)

Works perfectly, thanks!

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.