Forum Discussion
Count counting some items twice
- 1 year ago
HI Justas4478,
Thank you for the clarification and work in identifying the root cause.
You are right, the inflated count was due to row duplication caused by the ItemNumber column, which introduced a lower granularity than necessary.
Since your reporting logic considers the combination of Date, Document Number, and SKU as the lowest meaningful level, aggregating at that level is both valid and recommended.Given that these fields are located in separate dimension tables, using the corresponding foreign keys from the 'Outbound Delivery' fact table is the most efficient and model-aligned solution.
Given that these fields reside in separate dimension tables, using the corresponding foreign keys from the 'Outbound Delivery' fact table is the most efficient and model aligned solution.
Corrected Count =
COUNTROWS(
SUMMARIZE(
'Outbound Delivery',
'Outbound Delivery'[DateKey],
'Outbound Delivery'[OutboundDeliveryDocumentKey],
'Outbound Delivery'[ProductKey]
)
)We'll continue exploring if there are further opportunities or edge cases to enhance this further, but for now, your current solution is accurate and reliable.
If the solution worked for you, please click Accept as Solution and feel free to leave a Kudos for visibility.
Thank you,
Sahasra.
Hi Justas4478 ,
This is a classic scenario in Power BI and other data tools, where the COUNT measure counts some items twice—almost always due to the underlying data model and table relationships, not the measure itself. Let’s break down the possible reasons and how to fix it:
Why the COUNT is Incorrect
Duplicates in Source Table:
If your [Actual] column or the table 'Outbound Delivery' contains duplicate rows for the same item, COUNT will count each row, even if the value is the same.Many-to-Many or Incorrect Relationships:
If your data model has many-to-many relationships, or if the 'Outbound Delivery' table is related to other tables in a way that creates duplicate rows in the result (for example, due to improper joins or ambiguous relationships), the COUNT will sum up those duplicates.Expanded Data in Visual:
If your visual’s granularity is higher than the actual base data, (e.g., you are grouping or joining with another table), the COUNT will reflect that expanded set.
How To Diagnose
- Check the Data Table:
Go to Data view and use "Remove Duplicates" on the [Actual] column. See if duplicate rows exist. - Look at Relationships:
In Model view, check all relationships connected to 'Outbound Delivery'. If there are more than one, or if there are bidirectional or many-to-many relationships, these can multiply your row count. - Drill Down:
Filter a problematic value (e.g., 2.00) and check all rows—do you see multiple rows with the same value? If yes, that’s your source of duplication.
How To Fix
A. If you want to count unique values (distinct):
Use the DISTINCTCOUNT function in DAX:
Count of Unique Outbound Deliveries = DISTINCTCOUNT('Outbound Delivery'[Actual])This will count each unique [Actual] value only once.
B. If you want to count unique rows:
If you have a row ID or unique key, use:
Count of Unique Rows = DISTINCTCOUNT('Outbound Delivery'[RowID])C. To find the duplicates:
You can add a calculated column:
Duplicate Check =
CALCULATE(
COUNTROWS('Outbound Delivery'),
ALLEXCEPT('Outbound Delivery', 'Outbound Delivery'[Actual])
)Then filter where [Duplicate Check] > 1 to find which values are duplicated.
General Advice
- The COUNT measure is not “wrong”—it simply counts all rows, including duplicates created by your data structure or relationships.
- Use DISTINCTCOUNT to get unique items.
- Always check relationships and data granularity in your model.
If you share a sample of your data model or clarify the relationships, I can provide even more tailored advice. But with these steps you should be able to pinpoint and fix the double-counting issue.
Let me know if you need detailed step-by-step instructions!
translation and formatting supported by AI
burakkaragoz Really good explanation, but I can't do calculated columns only measures.
Since 3rd party is managing data cube and it is set to live connection mode.
Forcing to use only measures.