Forum Discussion
slicer no selection
Hello, being new in power BI, I have a lot of beginner questions!
I want to count and display the disctint values of a specific column, for that I created a measure using DISTINCTCOUNT function.
In addition, I have a slicer on a different column and people can select all or only 1 of the options, there is also the possibility to select nothing.
When this case happens, I would like that the count is 0 but indeed it is not, it counts me still like having the full table.
Did I miss something about slicer/filter logic? i guess already if the outcome would be blank() then I could use an IF statement with isblank() but here it is even not the case.
Thanks for your help,
Hi Anonymous,
I have modified my formula with countProd, you could refer to it:
countProd = IF(ISFILTERED(Sheet7[Product]),DISTINCTCOUNT(Sheet7[Product]),IF(ISBLANK(SELECTEDVALUE(Sheet7[Product])),0))
Result:
Hope it could help you.
Regards,
Daniel He
8 Replies
- v-danhe-msftMicrosoft Employee
Hi Anonymous,
Could you please offer me some sample data to have a test and post your desired result?
Regards,
Daniel He
- AnonymousNot applicable
Thanks for offering your help,
Attached is my table and my display (with my slicer and my attempts to count)
Indeed I did two attempts of measures
countProd = DISTINCTCOUNT(Sheet7[Product]) countProd with is filtered = if(ISFILTERED(Sheet7[CTRY]);DISTINCTCOUNT(Sheet7[Product]);0)
for countProd, my problem is that the results when select all is checked and when there is nothing checked is the same (4) whereas it should be blank and after I can put a if condition for this blank
for countProd with is filtered, it solved the problem when nothing is selected but now when > 1 thing is selected is filtered = false and then it put 0 while it should be 4.
Thanks a lot!
- v-danhe-msftMicrosoft Employee
Hi Anonymous,
I have modified your formula, you could refer to it:
countProd = IF(ISBLANK(SELECTEDVALUE(Sheet7[Product])),0,DISTINCTCOUNT(Sheet7[Product]))
countProd with is filtered = if(ISFILTERED(Sheet7[CTRY]),0,DISTINCTCOUNT(Sheet7[Product]))
Result:
You could also download the pbix file to have a view.
Regards,
Daniel He