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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

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
Frequent Visitor

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.