Reply
KapGun
Regular Visitor
Partially syndicated - Outbound

Measure to calculate share of rows selected by slicer

I need to calculate share of rows which have a value selected in slicer.

 

For testing I created two measures, first counting all rows:

  LT_All = COUNT(Events[Reason])
 
Then counting only selected rows
  LT_Selected =
  Var  Reason_selected =
  CALCULATE ( COUNT ( 'Events'[Reason]), ALLSELECTED ( 'Events' ) )
  Return
  Reason_selected
 
And finally wrote the actual measure
  Share =
  Var Reason_selected = CALCULATE ( COUNT ( 'Events'[Reason]), ALLSELECTED ( 'Events' ) )
  Var Reason_All = COUNT(Events[Reason])
  Return
  Reason_selected/Reason_All

 

However, it shows "100%" :

KapGun_0-1709307598685.png

What am I doing wrong?

1 ACCEPTED SOLUTION
v-jingzhan-msft
Community Support
Community Support

Syndicated - Outbound

Hi @KapGun 

 

You can use this for all, using ALL to remove all filters on the table. 

LT_All = CALCULATE(COUNT(Events[Reason]), ALL('Events' ))

Share:

 Share =
 Var Reason_selected = CALCULATE ( COUNT ( 'Events'[Reason]), ALLSELECTED ( 'Events' ) )
 Var Reason_All = CALCULATE ( COUNT(Events[Reason]), ALL ( 'Events' ) )
 Return
 Reason_selected/Reason_All

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

View solution in original post

2 REPLIES 2
v-jingzhan-msft
Community Support
Community Support

Syndicated - Outbound

Hi @KapGun 

 

You can use this for all, using ALL to remove all filters on the table. 

LT_All = CALCULATE(COUNT(Events[Reason]), ALL('Events' ))

Share:

 Share =
 Var Reason_selected = CALCULATE ( COUNT ( 'Events'[Reason]), ALLSELECTED ( 'Events' ) )
 Var Reason_All = CALCULATE ( COUNT(Events[Reason]), ALL ( 'Events' ) )
 Return
 Reason_selected/Reason_All

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

Syndicated - Outbound

Great, works like a charm!

Thanks mate 🙂

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)