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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jcavl
Regular Visitor

How to Sum when using aggregate data table

I have a datatable that looks like this

orderitemshipped weekshipped month
order 1item 117-Sepsep
order 1item 1214-Sepsep
order 1item 1321-Sepsep
order 2item 215-Octoct
order 2item 225-Octoct
order 3item 3121-Sepsep
order 3item 325-Octoct
order 3item 335-Octoct
order 4item 4419-Octoct


The total distinct orders are 4, however I need to agggreagte this at a week and month level before bringing the data table into Power BI.
The issue is an order can be shipped across multiple weeks, and sometimes months. Bringing the aggregate data table and using Sum in Power BI fetches me the wrong results.

shipped monthcount distinct orders
sep2
oct3
sum in pbi5

 

shipped weekcount distinct orders
7-Sep1
14-Sep1
21-Sep2
5-Oct2
19-Oct1
sum in pbi7


Using the data table as is, and aggregating in Power BI is not feasiable.
How would I show 2 orders in Sept, and 3 orders in Oct with a total of 4 orders shipped, instead of 5 orders shipped in Power BI?  

9 REPLIES 9
Ritaf1983
Super User
Super User

Hi @jcavl 

It seems your main issue comes from trying to aggregate without a proper Date table. When an order can appear in multiple weeks or months, simple sums will always overcount.

To fix this:

Ensure the [shipped] column is a real Date (convert it in Power Query if needed).

Create a Calendar table with columns for Date, Month, Year, and WeekOfMonth:

Calendar =
ADDCOLUMNS (
CALENDAR ( MIN ( Orders[shipped] ), MAX ( Orders[shipped] ) ),
"Year", YEAR ( [Date] ),
"Month", FORMAT ( [Date], "MMM yyyy" ),
"WeekOfMonth",
WEEKNUM ( [Date], 2 ) - WEEKNUM ( EOMONTH ( [Date], -1 ), 2 ) + 1
)


Relate the Calendar table to your Orders table on [shipped].

Create a measure:

Distinct Orders = DISTINCTCOUNT ( Orders[order_id] )


Use Month or WeekOfMonth from the Calendar table in your visuals.
This will correctly show 2 orders in September and 3 in October, total 4 overall.

If your “week” column is a custom label instead of a real date, follow the same logic — create a helper table with unique week and month values and relate it (or use it as a slicer).

For more details:

https://radacad.com/all-in-one-script-to-create-calendar-table-or-date-dimension-using-dax-in-power-...

https://radacad.com/power-bi-basics-of-modeling-star-schema-and-how-to-build-it/

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi Rita<
Thanks for the detailed answer, but this is an issue of double counting distinct orders. The original data table has over 50 cols, and 70 mil rows and counting. I cannot bring that data table into Power BI. I need to aggregate the table in SQL before attempting to bring it into Power BI.

Hi @jcavl ,
Thanks for reaching out to the Microsoft fabric community forum.  

Thanks for the update. The suggestion to aggregate in SQL using distinct combinations (for example, order + shipped_month) is correct and should help avoid double counting before the data reaches Power BI.

 

However, since the issue involves large data volumes and complex aggregation logic, it may need deeper review of your SQL model and data structure.

If the issue still persists on your end, we recommend reaching out to our Power BI certified solution partners. These are highly experienced professionals who can provide in-depth technical assistance and offer tailored solutions based on your specific needs. You can explore the list of trusted partners here:

Power BI Partners | Microsoft Power Platform

You’re always welcome to continue engaging with the community as well,
Should you need further assistance in the future, we encourage you to reach out via the Microsoft Fabric Community Forum and create a new thread.

we truly appreciate your active participation in the Microsoft Fabric Community.

 

Best Regards, 
Community Support Team

 

 

Hi @jcavl ,

We are following up once again regarding your query. Could you please confirm if the issue has been resolved through the Power BI Parteners? 

If the issue has been resolved, we kindly request you to share the resolution or key insights here to help others in the community. 

 

Thank you.

Ticket not opened. Issue (un)resolved. Report no longer needed.

Thank you. 

jcavl
Regular Visitor

Question can be closed.
I don't know how to do that.

Hi @jcavl ,

Thank you for the update.

Gabry
Super User
Super User

Hey man,

I think you just need to build a measure like this:

Order count= DISTINCTCOUNT('Table'[order])

 

Gabry_1-1761165404698.png

 

 

jcavl
Regular Visitor

Hi, 
This is an issue of double counting distinct orders. The original data table has over 70 mil rows. I cannot bring that data table into Power BI and then create a measure. I need to aggregate the table in SQL before attempting to bring it into Power BI.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors