Forum Discussion

threw001's avatar
threw001
Helper III
1 year ago
Solved

Filtering Dates help in Power Query please!

Hi there,   I would like to set a filter on a date field in Power Query. The filter I would like to set is following: Include all dates on or before 30 days from now. For example if the date toda...
  • dharmendars007's avatar
    dharmendars007
    1 year ago

    Hello threw001 , 

     

    Use the following M code to create the column for filtering, This code calculates the date 30 days before today

     

    DateTime.LocalNow() - #duration(30, 0, 0, 0)

     

    After creating this custom column, filter the date field by choosing dates that are less than or equal to the result of the formula

     

    Table.SelectRows(#"Previous Step", each [Date] <= Date.From(DateTime.LocalNow() - #duration(30, 0, 0, 0)))

     

    by this your data will dynamically filter to include all records with a date on or before 30 days from the current date, regardless of when the report is run

     

    If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

     

    Thank You

    Dharmendar S

    LinkedIN