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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
intrasight
Helper IV
Helper IV

Aggregating records with a date column to week, month, and quarter with SQL Server DirectConnect

Is this possible? Is there a standard M pattern for this? I didn't find anything here or Googling, but perhaps I'm asking the question the wrong way. I have daily data and I wish to group/aggregate by week or month or quarter. I was assuming that this would be easy in Power BI using M, but since I've found no samples, I am thinking perhaps not.

 

1 ACCEPTED SOLUTION

@intrasight

 

The errors is due to the limitation of DirectQuery mode. Since you're using SQL Server, the requirement can be easily achieved by queries as below. You can apply those queries individually when "get data".

select year(orderdate)[year],datepart(week,orderdate) [week],sum(sales) totalSales from orders
group by year(orderdate),datepart(week,orderdate)

select year(orderdate) [year],datepart(quarter,orderdate) [quarter],sum(sales) totalSales  from orders
group by year(orderdate),datepart(quarter,orderdate)

select dateadd(month,datediff(month,0,orderdate),0) [month] ,sum(sales) totalSales from orders
group by dateadd(month,datediff(month,0,orderdate),0)

Capture.PNG

Capture.PNG

View solution in original post

2 REPLIES 2
intrasight
Helper IV
Helper IV

I just tried adding this expression:

 

#"AddMonth" = Table.AddColumn(dbo_InventoryView, "Month", each Date.StartOfMonth([StorageDate]), type date)

 

But I get the error:

 

"This step results in a query that is not supported in DirectQuery mode"

@intrasight

 

The errors is due to the limitation of DirectQuery mode. Since you're using SQL Server, the requirement can be easily achieved by queries as below. You can apply those queries individually when "get data".

select year(orderdate)[year],datepart(week,orderdate) [week],sum(sales) totalSales from orders
group by year(orderdate),datepart(week,orderdate)

select year(orderdate) [year],datepart(quarter,orderdate) [quarter],sum(sales) totalSales  from orders
group by year(orderdate),datepart(quarter,orderdate)

select dateadd(month,datediff(month,0,orderdate),0) [month] ,sum(sales) totalSales from orders
group by dateadd(month,datediff(month,0,orderdate),0)

Capture.PNG

Capture.PNG

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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