Power Query - Is the date with the last 7 days?

shane_aldrich

Board Regular
Joined
Oct 23, 2009
Messages
148
I have a text file, and I want to filter the rows based on a column called "Sales Date" - I only want query rows if they occurred within the last 7 days of the max day within the "Sales Date" column.


Any help would be awesome!!!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi
Try
Code:
let
    Source = Csv.Document(File.Contents("d:\path\filename.csv"),[Delimiter=",",Encoding=437]),
    AddHead = Table.PromoteHeaders(Source),
    ChangedTypes = Table.TransformColumnTypes(AddHead,{{"Sales Date", type date}},"en-US"),
    MinDate = Table.Max(ChangedTypes, "Sales Date")[Sales Date]-#duration(7,0,0,0),
    NeededRows = Table.SelectRows(ChangedTypes, each [Sales Date]>=MinDate)
in
    NeededRows
Regards,
 
Upvote 0

Forum statistics

Threads
1,225,562
Messages
6,185,675
Members
453,314
Latest member
amitojsd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top