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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lawada
Helper III
Helper III

calculate value for previous week of the month

hi everyone

 

im trying to find week over week change for weeks of the month 

ex. if we are now in the month of FEB2022, weeks would be:

W1: 1-2 till 5-2

W2: 6-2 till 12-2

W3:13-2 till 19-2

W4: 20-2 till 26-2

W5: 27-2 till 28-2

 

i want to calculate the week over week change and for that i need to find the value for previous week

example with data:

W1: 2478

W2: 3457

W3:3359

W4:3456

W5:574 

week over week change for W2 would be (3457-2478)/2478=39.5

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @lawada 

 

You can try the following methods.

Table:

DATE = CALENDAR(DATE(2022,2,1),TODAY())

Column:

Weekday = WEEKDAY([Date],1)
Week No = 
Var minweekday=CALCULATE(MIN('DATE'[Weekday]),FILTER('DATE',[Date]=MIN('DATE'[Date])))
Var week=CALCULATE(COUNT('DATE'[Weekday]),FILTER('DATE',[Date]<=EARLIER('DATE'[Date])&&[Weekday]=1))
Return
IF(minweekday<>1,week+1,week)
Week = "W"&[Week No]

vzhangti_0-1646288582715.png

Measure:

Current week value = SUM('Table'[Value])
Previous week value = 
CALCULATE(SUM('Table'[Value]),FILTER(ALL('DATE'),[Week No]=SELECTEDVALUE('DATE'[Week No])-1))
Change = DIVIDE([Current week value]-[Previous week value],[Previous week value])

vzhangti_1-1646288869229.png

Is this the output you expect?

 

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
v-zhangti
Community Support
Community Support

Hi, @lawada 

 

You can try the following methods.

Table:

DATE = CALENDAR(DATE(2022,2,1),TODAY())

Column:

Weekday = WEEKDAY([Date],1)
Week No = 
Var minweekday=CALCULATE(MIN('DATE'[Weekday]),FILTER('DATE',[Date]=MIN('DATE'[Date])))
Var week=CALCULATE(COUNT('DATE'[Weekday]),FILTER('DATE',[Date]<=EARLIER('DATE'[Date])&&[Weekday]=1))
Return
IF(minweekday<>1,week+1,week)
Week = "W"&[Week No]

vzhangti_0-1646288582715.png

Measure:

Current week value = SUM('Table'[Value])
Previous week value = 
CALCULATE(SUM('Table'[Value]),FILTER(ALL('DATE'),[Week No]=SELECTEDVALUE('DATE'[Week No])-1))
Change = DIVIDE([Current week value]-[Previous week value],[Previous week value])

vzhangti_1-1646288869229.png

Is this the output you expect?

 

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.

Whitewater100
Solution Sage
Solution Sage

Hello:

Having a date table with week no will help. Please see attached file with answer. As you get into future years a minor tweak to the measure will take that into account. Hope this helps. Please see link below.

 

https://drive.google.com/file/d/1IWRpNWJdj-DM22-91V068oSkQt8PQK5-/view?usp=sharing

A week column in the date table can help as long as it matches what @lawada is trying to do.

 

Rather than WEEKNUM ( Dates[Date] ), something more like ROUNDUP ( DAY ( Dates[Date] ) / 7, 0 ) might do the trick.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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