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
Anonymous
Not applicable

This Week vs Last Week

Hi,

I have a text column called 'Week Indicator' that I want to create based on date values between last week and this week.

If the date is in last week then value = 'Last Week'
If the date is in this week then value = 'This Week'

What is the best way to do this?

I can't seem to use the query Date.IsInPreviousWeek for some reasoonm in the column function..

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi guys,

 

Thanks for thereplies.

 

Yes v-caliao-msft, you are correct there is no function to find date in current week which is pretty annoying.

 

That said, I turned to power query and just added a new column with those existing methods:

 

Date.IsInCurrentWeek

Date.IsInPreviousWeek

 

based on this thread: http://community.powerbi.com/t5/Desktop/Add-column-for-Last-Week-to-table/m-p/157463#M68286

 

View solution in original post

3 REPLIES 3
v-caliao-msft
Microsoft Employee
Microsoft Employee

@Anonymous,

 

In Power query, there is Date.IsInCurrentWeek functin that returns a logical value indicating whether the given Date/DateTime/DateTimeZone occurred during the current week, as determined by the current date and time on the system.

To check if the date is in previous week, there is no such a function to achieve this directly. You need to return the week number and previous week number, and check if the week number=previous week number. We can use Date.WeekOfYear function in Power query to get the week number.

 

Regards,

Charlie Liao

Anonymous
Not applicable

Hi guys,

 

Thanks for thereplies.

 

Yes v-caliao-msft, you are correct there is no function to find date in current week which is pretty annoying.

 

That said, I turned to power query and just added a new column with those existing methods:

 

Date.IsInCurrentWeek

Date.IsInPreviousWeek

 

based on this thread: http://community.powerbi.com/t5/Desktop/Add-column-for-Last-Week-to-table/m-p/157463#M68286

 

GilbertQ
Super User
Super User

hi @Anonymous

 

Have a look at this solution which should enable you to create the columns that you need. 

 

You can then use the columns IsInCurrentWeek and IsInLastWeek

 

https://community.powerbi.com/t5/Desktop/Display-this-week-amp-this-month-data/m-p/11207#M2459





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

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.