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



## shane_aldrich (Nov 6, 2015)

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!!!


----------



## anvg (Nov 8, 2015)

Hi
Try 

```
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,


----------

