Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi team,
I am having a table called Category where i have two columns "Category" and "Items"
I am applying category in filter and i wanted to have count of matched items from the selected categories
can anyone give me DAX to acheive it
Thanks
Solved! Go to Solution.
Hi @rajeshapunu1234 ,
I am not sure if I understood your question correctly.
Based on the example and description you provided, please try code as below to create a measure.
My Sample:
Count of matched items =
VAR Sel_Category = SELECTEDVALUE ( 'Table'[Category] )
VAR Category_Trim =
SUBSTITUTE ( SUBSTITUTE ( Sel_Category, "Category", "item" ), " ", "" )
RETURN
COUNTX ( FILTER ( 'Table', 'Table'[Items] = Category_Trim ), 'Table'[Items] )
When you select "Category 1" in the slicer, Result is as below.
Is this the result you expect?
Please correct me if I misunderstood your needs.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @rajeshapunu1234 ,
I am not sure if I understood your question correctly.
Based on the example and description you provided, please try code as below to create a measure.
My Sample:
Count of matched items =
VAR Sel_Category = SELECTEDVALUE ( 'Table'[Category] )
VAR Category_Trim =
SUBSTITUTE ( SUBSTITUTE ( Sel_Category, "Category", "item" ), " ", "" )
RETURN
COUNTX ( FILTER ( 'Table', 'Table'[Items] = Category_Trim ), 'Table'[Items] )
When you select "Category 1" in the slicer, Result is as below.
Is this the result you expect?
Please correct me if I misunderstood your needs.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This dax giving distince count of the selected category
but the need is count of matched items only
Example
Category 1 item1
Category 1 item2
Category 2 item1
Category 2 item3
Category 3 item1
Category 3 item4
from the above table the output of matched item count should be 1 as "Item1" available in the all three category
your result is giving 4 as it count distince of the all items not only matched items
thanks
Hi @rajeshapunu1234
Please use
ItemsQty = COUNT('yourtable'[itemid])
Let me know if that works for you
If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the Thumbs Up 👍 button if this comment helps you.
Thanks
Pijush
Linkedin
Proud to be a Super User! | |
no this also not giving the matched count
I wanted to have matched count only
please suggest DAX
Hi @rajeshapunu1234
I am using TableCategoryItem
| Category 1 | Item A |
| Category 1 | Item B |
| Category 2 | Item A |
| Category 2 | Item B |
| Category 2 | Item C |
| Category 2 | Item D |
| Category 3 | Item A |
| Category 3 | Item B |
| Category 3 | Item C |
The measure working
Find the PBIX and if it will not working in your data model,
Please share smaple PBIX file link
https://drive.google.com/file/d/160Mz1MriG4-yoYb8smaqUQn00wU17CP8/view?usp=sharing
Let me know if that works for you
If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the Thumbs Up 👍 button if this comment helps you.
Thanks
Pijush
Linkedin
Proud to be a Super User! | |
A standard distinct count will do the work (if you need the distinct counts).
ItemsQty = distinctcount('yourtable'[itemid])
Or count rows if you need to count duplicates too
ItemsQty = countrows('yourTable')
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.