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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
modxplus
Frequent Visitor

FIlter to Last Week Only

I am trying to set filter this table to a "Last Week Only" view. 

I cant use the normal filter to last week due to the fact that my weeks run from Saturday to Friday and the date filter in Power Query runs Sunday to Saturday.

I am sure there is an easier way to do this but my thought process:

- I have a list view of dates with a week number that corresponds to the Sat to Fri

- The "Date Check" will populate a 1 on todays date

- The Last Week Number is just the week number minus the 1

**My problem is i am trying to get a custom column there in the "Last Week Check" so when Week Number = Last Week Number then 1 else 0. Then i can just filter to the 1 in that column and always be able to show last week. But I cant get that matching column to work correctly and have the highlighted rows in the "last week check" populate anything

Last Week View.PNG

1 ACCEPTED SOLUTION

Just do

 

Table.SelectRows(PriorStepOrTableName,each Date.WeekOfYear(Date.From(DateTime.LocalNow()), Day.Saturday)-1)

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

View solution in original post

3 REPLIES 3
watkinnc
Super User
Super User

For your Week Number Column, your formula should be Table.AddColumn(PriorStepOrTableName, "Week Number", each Date.WeekOfYear([Date], Day.Saturday), Int64.Type)

 

That makes Saturday your first day of the week.

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Perfect. Yes that worked and has Sat as the first day of the week now. 

Do you know how you would do the second piece where i can do a Week Number = Last Week Number then 1 else 0 formula to only filter to last week

Just do

 

Table.SelectRows(PriorStepOrTableName,each Date.WeekOfYear(Date.From(DateTime.LocalNow()), Day.Saturday)-1)

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors