Forum Discussion

aatish178's avatar
aatish178
Helper IV
2 years ago
Solved

Filtering date column data in power query

Hi All, I want to filter a date column to only show last 3 years of data from today's date in power query. The filtering should be from today's date and it would be dynamic after every day. Can you...
  • ronrsnfld's avatar
    2 years ago

    I don't think you can do that in Power Query. I believe you will need to load the entire data set, and then filter.  M-code would be something like:

    Table.SelectRows(#"Previous Step", each [date_column_to_filter_on] > Date.AddYears(Date.From(DateTime.FixedLocalNow()),-3))

    If you only want to LOAD the past three years, that would need to be done either at the data source, or, depending on the data source, perhaps in your connector (eg if it involves an api perhaps there is an argument to restrict the data).