Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
10 | |
10 | |
9 | |
7 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
10 |