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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Count selected values in a slicer

Hi all ,

 

I'm using 

TestSlicerCount =
COUNTROWS(VALUES(FinalTable[Month])) , to count the number of selected values in a slicer with 12 values, works fine but when there are no selections it shows 12 instead of 0. How can i avoid this?
pbi5.PNGpbi6.PNG
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

I managed to make it work , thank you @amitchandak .

 

I used this , 

TestSlicerCount = IF(ISFILTERED(FinalTable[Month]), COUNTROWS(VALUES(FinalTable[Month])),0)

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous . try like

countx(allselected(table),table[column])

 

Or

measure =
Var _1 = countx(allselected(table),table[column])
var _2 = countx(all(table),table[column])

return
if(_1=_2 =0,_1)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

@amitchandak  ,

 

That didn't work , it shows the value as 448 now , i had edited the message just before you replied , maybe you can get a better understanding now

@Anonymous , try

measure =
Var _1 = calculate(distinctCOUNT(table[column]),allselected(table))
var _2 = calculate(distinctCOUNT(table[column]),all(table))

return
if(_1=_2 =0,_1)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Anonymous
Not applicable

I managed to make it work , thank you @amitchandak .

 

I used this , 

TestSlicerCount = IF(ISFILTERED(FinalTable[Month]), COUNTROWS(VALUES(FinalTable[Month])),0)

Is it possible to ignore some months for slicer count? so for example count all selected on slicer, except 9,10,11,12
thanks!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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