Forum Discussion
Count function is doubling
Hi
I have a card visual.
The count function is doubling everything. Both via a measure and via the "aggregation" option where you choose sum, average, count etc.
I've checked the table. There are definitely only 481 rows when I filter with the exact same filters i'm using in the visual.
I've removed all relationships from the table and tried again, still getting doubled to 962.
Any ideas?
Hi
Apologies, my dataset had duplicate values under a different file source name - I was filtering on file source assuming they were the only ones containing the data I was analysing - there were other files that had the exact same data. Just another by-product of having to work around your IT team, rather than with them.
5 Replies
- danextianSuper User
In the table view, does it also show only 481 rows? Adding fields to a table visual can remove duplicate rows, so it’s not always a direct comparison of the actual row count in the dataset. The COUNT function counts all rows in a column regardless of duplicates—try using DISTINCTCOUNT instead. If the issue persists, consider sharing a non-confidential copy of the PBIX file.
- Ray_MindsSolution Supplier
Explanation:
The issue comes from how COUNT works in DAX and visuals:- COUNT(Table[Column]) counts non-blank values in that column, not rows.
- If the column being counted has multiple values per row in the current filter context (or is expanded by auto-exist combinations in the visual), the count can double.
- The built-in “Count” aggregation in visuals behaves the same way.
Solution:
Use COUNTROWS instead of COUNT:
This counts the actual rows in the filtered table, so your card should display 481.
If you need unique values of a column, use: DISTINCTCOUNT
UniqueValue = DISTINCTCOUNT ( Table[Column] )
How to Validate- Add both RowCount and your original measure to a table visual with the same filters.
- Confirm RowCount = 481 while COUNT = 962.
- Replace the card’s aggregation with RowCount
- ryan_mayuSuper User
- v-ssriganeshCommunity Support
Hi CountisBroken,
Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to Ray_Minds & danextian for sharing valuable insights.
Could you please confirm if your query has been resolved by the provided solutions? This would be helpful for other members who may encounter similar issues.
Thank you for being part of the Microsoft Fabric Community.
- CountisBrokenNew Member
Hi
Apologies, my dataset had duplicate values under a different file source name - I was filtering on file source assuming they were the only ones containing the data I was analysing - there were other files that had the exact same data. Just another by-product of having to work around your IT team, rather than with them.