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
rezaaditia
Helper III
Helper III

get last calendar week of data

Hi All -

 

I understand using power BI filter, we can filter the date to get last calendar weeks.

But the problem that i faced using existing filters, the count start from Sunday to Saturday while my company cycle data is from Monday to Sunday.

Can you please help to assist to create filter in measure/dax to get :

- 1 last calendar week (Data on Dec 9 - Dec 15)

- 2 last calendar week (Data on Dec 2 - Dec 8  ) 

 

Thanks 

 

1 ACCEPTED SOLUTION
rajulshah
Super User
Super User

Hello @rezaaditia,

 

You can create a calculated column as below:

Calendar Week = WEEKNUM ( [Date] , 2)
Current Year = IF(YEAR(Dates[Date])=YEAR(NOW()),1,0)
-1 Last Week = IF(Dates[Current Year]=1 && (WEEKNUM(TODAY())-1)=Dates[Calendar Week],1,0)
-2 Last Week = IF(Dates[Current Year]=1 && (WEEKNUM(TODAY())-2)=Dates[Calendar Week],1,0)

 

Hope this helps.

View solution in original post

1 REPLY 1
rajulshah
Super User
Super User

Hello @rezaaditia,

 

You can create a calculated column as below:

Calendar Week = WEEKNUM ( [Date] , 2)
Current Year = IF(YEAR(Dates[Date])=YEAR(NOW()),1,0)
-1 Last Week = IF(Dates[Current Year]=1 && (WEEKNUM(TODAY())-1)=Dates[Calendar Week],1,0)
-2 Last Week = IF(Dates[Current Year]=1 && (WEEKNUM(TODAY())-2)=Dates[Calendar Week],1,0)

 

Hope this helps.

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.