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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Analitika
Post Prodigy
Post Prodigy

Calculate sum by weeks in Power BI

Hello,

 

How to calculate let say sales by weeks? Now I have sum per all period. Starting weekday is Sunday.

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @Analitika ,

 

Let's assume there is a table with Date column(from 2021/1/1/ to 2022/5/20) and Value column.

If you want to calculate the sum value of each week  and the starting weekday is Sunday, please firstly create a Week column using WEEKNUM()

Week = WEEKNUM([Date],1)   // the second parameter is set as 1 which means the starting weekday is Sunday.

Then create a sum column or measure:

Sum by week column = CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Week] ,'Table'[Date].[Year]))
Sum by week measure = CALCULATE(SUM('Table'[Value]),FILTER('Table',YEAR([Date])=YEAR(MAX('Table'[Date])) && [Week]=MAX('Table'[Week])))

Output:

Eyelyn9_1-1653024776628.png

 

Best Regards,
Eyelyn Qin
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

2 REPLIES 2
sajjadansari
Regular Visitor

WeekNumber = CONCATENATE("Week ",WEEKNUM(Tablename[Date],2)-WEEKNUM(EOMONTH(Tablename[Date],-1)+1)+1)
v-eqin-msft
Community Support
Community Support

Hi @Analitika ,

 

Let's assume there is a table with Date column(from 2021/1/1/ to 2022/5/20) and Value column.

If you want to calculate the sum value of each week  and the starting weekday is Sunday, please firstly create a Week column using WEEKNUM()

Week = WEEKNUM([Date],1)   // the second parameter is set as 1 which means the starting weekday is Sunday.

Then create a sum column or measure:

Sum by week column = CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Week] ,'Table'[Date].[Year]))
Sum by week measure = CALCULATE(SUM('Table'[Value]),FILTER('Table',YEAR([Date])=YEAR(MAX('Table'[Date])) && [Week]=MAX('Table'[Week])))

Output:

Eyelyn9_1-1653024776628.png

 

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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