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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Jayaselvan
Helper II
Helper II

Daily Data to Weekly Data by Aggregation

I have daily Sales Quantity Data. I need to Summarize the table on weekly Level.

The weekly summary table should have date(Wednesday) and Aggregated Sales Quantity(from Thur to Wed) Columns.

Input Table (Daily Data):

Screenshot from 2022-08-18 10-33-19.png

 

 

 

 

 

 

 

 

 

Expected Output Table(Weekly Data):

Screenshot from 2022-08-18 10-33-41.png

 

 

Please let me know If I am not clear. 

Thanks in advance!

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Jayaselvan actually it is pretty straight forward, first you need to add a calendar dimension in your model, as a best practice when you are working with dates, always use a calendar dimension. 

 

In this new calendar dimension table, add a following column:

 

Week Date = 
VAR __dow = WEEKDAY ( 'Calendar'[Date], 3)
VAR __days = 2 - __dow 
VAR __newDays = if ( __days < 0, 9 - __dow, __days )
RETURN
'Calendar'[Date] + __newDays 

 

Set relationship between this new calendar table with the transaction table, which will be one to many relationship.

 

To visualize, use table visual, drop week date column from calendar dimension and sum sales qty from transaction table, and you will see the sum by each week starting from Thur - Wed.

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table with a calculated column formula for Weekday.  Create a relationship (Many to One and Sngle) from the Date column of your Data Table to the Date column of the Calendar Table.  To your visual, drag Date and Weekday from the Calendar Table.  Write these measures

Qty = sum(Data[Sales Qty])

Qty for week ended = if(calendar[weekday]="Wednesday",calculate([Qty],datesbetween(calendar[Date],min(calendar[date])-6,min(calendar[date]))),blank())

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@Jayaselvan actually it is pretty straight forward, first you need to add a calendar dimension in your model, as a best practice when you are working with dates, always use a calendar dimension. 

 

In this new calendar dimension table, add a following column:

 

Week Date = 
VAR __dow = WEEKDAY ( 'Calendar'[Date], 3)
VAR __days = 2 - __dow 
VAR __newDays = if ( __days < 0, 9 - __dow, __days )
RETURN
'Calendar'[Date] + __newDays 

 

Set relationship between this new calendar table with the transaction table, which will be one to many relationship.

 

To visualize, use table visual, drop week date column from calendar dimension and sum sales qty from transaction table, and you will see the sum by each week starting from Thur - Wed.

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Thanks fot the tips. Will follow the same in future.

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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