Forum Discussion

ovetteabejuela's avatar
ovetteabejuela
Impactful Individual
8 years ago
Solved

PowerQuery: Filter Top N

In Power Query, is there an equivalent function to filter top N items.   What I'm trying to do is filter on the latest 7 days and they don;t have to be consecutive days - just the latest 7 days ava...
  • Anonymous's avatar
    Anonymous
    8 years ago

    HI ovetteabejuela,

     

    You can refer to below steps to filter the dynamic last 7 days:

     

    1. Add custom steps to find out the last date from current table.

    Custom1 = List.Max(#"Changed Type"[Date])

     

     

    2. Enable date filter on date column and use above variable as the parameter.

    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Date] >= Date.AddDays(List.Max(#"Changed Type"[Date]),-7))

    Filtered tableOriginal tableRegards,

    Xiaoxin Sheng