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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
monojchakrab
Resolver III
Resolver III

week on week comparison

Hiya All,

 

I am trying to do a same week last month and previous week same month comparison.

 

Is there any function to do that or a guide to a measure which can help me do that?

 

I have a data table (attached), which has the weeknumber for every month with the date ranges (e.g. 1-7th is week 1, 8th-14th is week 2 and so on).

 

DateYEARMONTH NAMEMONTH NUMBERDAY NAMEWEEK NO
27-02-20222022Feb2Sun4
28-02-20222022Feb2Mon4
01-03-20222022Mar3Tue1
02-03-20222022Mar3Wed1
03-03-20222022Mar3Thu1
04-03-20222022Mar3Fri1
05-03-20222022Mar3Sat1
06-03-20222022Mar3Sun1
07-03-20222022Mar3Mon1
08-03-20222022Mar3Tue2
09-03-20222022Mar3Wed2
10-03-20222022Mar3Thu2
11-03-20222022Mar3Fri2
12-03-20222022Mar3Sat2
13-03-20222022Mar3Sun2
14-03-20222022Mar3Mon2
15-03-20222022Mar3Tue3
16-03-20222022Mar3Wed3
17-03-20222022Mar3Thu3
18-03-20222022Mar3Fri3
19-03-20222022Mar3Sat3
20-03-20222022Mar3Sun3
21-03-20222022Mar3Mon3
22-03-20222022Mar3Tue4

 

Thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@monojchakrab , Create week or month columns

 

min week start of month = minx(filter('Date',[Month Year] =earlier([Month Year])),[Week Start date])


week of month = datediff([min week start of month],[date],Week)+1
or
week of month = quotient(datediff([min week start of month],[date],day),7)+1

 

or

Start Month = eomonth([date],-1)+1

 

Month Week Start = [Start Month ] + QUOTIENT(datediff([Start Month],[date],day),7) *7

 

Create month rank

Month Rank = RANKX(all('Date'),'Date'[Month Start],,ASC,Dense)

 

MWTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank]) && [week of month] <=max([week of month])))
LMETD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1 && [week of month] <=max([week of month])))

 

 

refer

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
monojchakrab
Resolver III
Resolver III

@amitchandak , Amit, this is partly solving the problem...

 

What I am looking to solve is as follows :

 

If I have the table like this :

 

Apr : wk1...wk4//May : wk1...wk4

 

So I want to compare two columns of data as follows :

 

1. May : wk4/wk3;wk3/wk2;wk2/wk1 &

2. Sales for same week last month :

May wk1/Apr wk1//May wk2/Apr wk2//May wk3/Apr wk3//May wk4/Apr wk4

 

That does not seem to be possible with this code...

 

Note : I have added the columns in the date table as required as per this code 

monojchakrab
Resolver III
Resolver III

@amitchandak - I also watched your excellent video lesson on custom period. 

monojchakrab
Resolver III
Resolver III

@amitchandak Amit - can we modify this code to also include same week from last month?

amitchandak
Super User
Super User

@monojchakrab , Create week or month columns

 

min week start of month = minx(filter('Date',[Month Year] =earlier([Month Year])),[Week Start date])


week of month = datediff([min week start of month],[date],Week)+1
or
week of month = quotient(datediff([min week start of month],[date],day),7)+1

 

or

Start Month = eomonth([date],-1)+1

 

Month Week Start = [Start Month ] + QUOTIENT(datediff([Start Month],[date],day),7) *7

 

Create month rank

Month Rank = RANKX(all('Date'),'Date'[Month Start],,ASC,Dense)

 

MWTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank]) && [week of month] <=max([week of month])))
LMETD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1 && [week of month] <=max([week of month])))

 

 

refer

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak .

I will try this out and let you know

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors