Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello all,
I'm new to Power BI. As I learn, this community has been extremely helpful.
I'm stuck on a problem that I cannot solve and I haven't been able to find a solution on any forums. I'm trying to countrows based on slicer selection.
Sample table
Name / Product/ Price
John/B/20
Mike/C/15
Jule/A/10
Sarah/B/20
Jordan/D/20
John/C/15
Sarah/A/10
John/A/10
Slicer is the name column. When I click on that slicer, I want it to show me the number of rows. So for instance, if I click John, it will return 3. If I click Sarah, it will return 2. I checked the ouput of selectedvalue of this is the correct name.
So here is the forumla I've tried:
Measure =
VAR Selction = SELECTEDVALUE ('Table'[Name])
RETURN
CALCULATE (Countrows(Table), Table[Name]=Selection)
This returns a number that I cannot figure out the meaning. If I replace "Selection" variable with "John" in the equation, it gives me the correct output. I've actually tried "COUNT" functions that work as well. None of them work with this variable from the SELECTEDVALUE function. Any help would be much appreciated!
Solved! Go to Solution.
Hi @cleenfeet ,
You can use the Countx function
https://docs.microsoft.com/en-us/dax/countx-function-dax
Here are the steps you can follow:
1. Create measure.
Measure =
var _selectname=SELECTEDVALUE('Table'[Name])
return
COUNTX(FILTER(ALL('Table'),'Table'[Name]=_selectname),[Name])
2. Result:
If you need pbix, please click here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @cleenfeet ,
You can use the Countx function
https://docs.microsoft.com/en-us/dax/countx-function-dax
Here are the steps you can follow:
1. Create measure.
Measure =
var _selectname=SELECTEDVALUE('Table'[Name])
return
COUNTX(FILTER(ALL('Table'),'Table'[Name]=_selectname),[Name])
2. Result:
If you need pbix, please click here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @cleenfeet ,
See my picture, to get these results, please use this measure:
Count = COUNTROWS(ALLSELECTED('Table'))
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
12 | |
10 | |
10 | |
6 |