Forum Discussion

Judy101's avatar
Judy101
Frequent Visitor
1 year ago
Solved

Subset of dates from a table using Power query

Looking for Power query that helps list dates in a table from a pre-exisiting table. Conditions: 1. Minimum date should be 1st date of data from 26 months back. Example if today is 3/25/2025, I wan...
  • pankajnamekar25's avatar
    1 year ago

    Hello Judy,

     

    You can try below M script

     

    let

        Today = Date.From(DateTime.LocalNow()),

            StartDate = Date.StartOfMonth(Date.AddMonths(Today, -26)),

        DateList = List.Dates(StartDate, Duration.Days(Today - StartDate) + 1, #duration(1,0,0,0)),

        DateTable = Table.FromList(DateList, Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error)

    in

        DateTable

     

    Thanks,
    Pankaj

    If this solution helps, please accept it and give a kudos, it would be greatly appreciated.