Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Sah_123
Frequent Visitor

Discrepancy in Unique Order Count When Aggregating Data Using SUMMARIZE Function

Hi everyone,

I'm working with a large dataset and am encountering a discrepancy in the unique order count when aggregating the data. Here’s a summary of the issue:

Original Data:

I have a table with the following columns: Order ID, Defect Code, Product Line, Sales Batch, Month Difference, and City. Here is a sample of the data:

Order ID Defect Code Product Line Sales Batch Month Difference City
JC-000249QB00HApr-212AA
JC-000249QB40HApr-212AA
JC-001359QB40HApr-211AA
JC-001396QB40HApr-211AA
JC-002008QB40HApr-212AA
JC-003005AV19HApr-213AA
JC-003005AV19HApr-213AA
JC-003005AV19HApr-213AA
JC-M000825QB40HApr-211AA

Expected Results:

  • Unique Order Count: By city, product line, and sales batch level, I expect a total of 6 unique orders.

Aggregation Using SUMMARIZE Function:

I used the SUMMARIZE function to aggregate the data as follows:

dax
Copy code
SUMMARIZE( Tablename, City, Product Line, Sales Batch, "No of Orders", DISTINCTCOUNT(Order ID) )

Aggregated Output:

The output I received was:

Product Line City Sales Batch Month Difference Defect Code No of Orders
HAAApr-211QB403
HAAApr-212QB001
HAAApr-212QB402
HAAApr-213AV191

Issue:

When calculating the unique order count at the city level, the result is 7, whereas I expected it to be 6. The discrepancy arises due to the aggregation.

Question:

How can I correctly aggregate the data to ensure that the unique

order count matches the expected results? Is there a specific approach or adjustment I need to make to the SUMMARIZE function or the aggregation logic to account for this discrepancy?

Thank you in advance for your help!


Feel free to adjust the details as needed to fit your specific context.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Sah_123 

 

You can try the following methods.

Measure = 
Var _table=SUMMARIZE( 'Table', 'Table'[City], 'Table'[Product Line], 'Table'[Sales Batch Month], 'Table'[Order ID] )
RETURN
COUNTX(_table,[Order ID])

vzhangtinmsft_0-1725590714292.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @Sah_123 

 

You can try the following methods.

Measure = 
Var _table=SUMMARIZE( 'Table', 'Table'[City], 'Table'[Product Line], 'Table'[Sales Batch Month], 'Table'[Order ID] )
RETURN
COUNTX(_table,[Order ID])

vzhangtinmsft_0-1725590714292.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

bhanu_gautam
Super User
Super User

 @Sah_123 The discrepancy in the unique order count arises because the SUMMARIZE function is aggregating the data at a more granular level than you intend. 

 

Try using 

SUMMARIZE(
Tablename,
City,
Product Line,
Sales Batch,
"No of Orders", DISTINCTCOUNT(Order ID)
)

 

Then

VAR AggregatedTable =
SUMMARIZE(
Tablename,
City,
Product Line,
Sales Batch,
"No of Orders", DISTINCTCOUNT(Order ID)
)

RETURN
SELECTCOLUMNS(
AggregatedTable,
"City", [City],
"Product Line", [Product Line],
"Sales Batch", [Sales Batch],
"No of Orders", [No of Orders]
)

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






But wanted to keep  dfect code column also in aggregate table. in that case what to do.(in a slicer need to dfect code).

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.