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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
jb123
Frequent Visitor

Add column for Last Week to table

Hi,

 

I want to add a custom column to a table that will list the words Last Week.  I want to add this column so I can add slicer to the report so the users can filter to see just last week's data.  I haven't been able to get this working so as a workaround I created a duplicate copy of the table and in the edit query mode, I set a filter for last week.  This is not ideal as I have multiple tables and would prefer to have one table and let the user filter on the date.

 

Thanks.

 

 

 

 

 

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@jb123

 

Hi, add a custom Column:

 

= Table.AddColumn(#"YourPreviousStep", "LastWeek", each if Date.IsInPreviousWeek([Date]) then "Yes" else "No")




Lima - Peru

View solution in original post

5 REPLIES 5
Nayan_surya
Helper I
Helper I

Hi  @jb123 ,

 

This is a good approach but becomes impractical when you need like combination of these kinds of filters. I had faced a similar situation previously and what we ended up doing is getting a custom visual named Date picker by Powerviz. 

It had all the required features like

Multiple presets,

Default selection

Holidays

Invalid dates highlight and much more

So final result, the client was happy.

 

Nayan_surya_0-1702655780976.png

 

 

I think you should check them out.

Here is a link if you want to check this visual - https://appsource.microsoft.com/en-us/product/powerbivisuals/truvizinc1674781244292.date-picker-by-p...  (I believe they offer a free version too)

 

Vvelarde
Community Champion
Community Champion

@jb123

 

Hi, add a custom Column:

 

= Table.AddColumn(#"YourPreviousStep", "LastWeek", each if Date.IsInPreviousWeek([Date]) then "Yes" else "No")




Lima - Peru

Hi buddy,

 

I have the same doubt but since I am pretty new to Power BI, please explain this formula a bit more.
Like what is Table.Addcolum etc.

 

Please help!

 

Regards

Rahul

Vvelarde
Community Champion
Community Champion

@rahulv

 

Hi, This can do in Query Editor using Power Query Langauge.

 

= Table.AddColumn(#"YourPreviousStep", "LastWeek", each if Date.IsInPreviousWeek([Date]) then "Yes" else "No")

 

In this case the sentence do:

 

Add a Column named "LastWeek"  and fill with if Date is in Previous Week Put Yes else No.

 

Also you can create with Add Custom Column with this code:

 

PWeek.png

 

 




Lima - Peru

This worked - thank you!

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.