Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Judy101
Frequent Visitor

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 want the minimum date to be 2/1/2023.

2. 

1 ACCEPTED SOLUTION
pankajnamekar25
Super User
Super User

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.

View solution in original post

5 REPLIES 5
v-ssriganesh
Community Support
Community Support

Hi @Judy101,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-ssriganesh
Community Support
Community Support

Hi @Judy101,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

v-ssriganesh
Community Support
Community Support

Hi @Judy101,

Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @pankajnamekar25 & @danextian for sharing valuable insights.

Could you please confirm if your query has been resolved with the solutions provided? If they have, kindly mark the helpful response and accept it as the solution. This will assist other community members in resolving similar issues more efficiently.

Thank you.

danextian
Super User
Super User

Hi @Judy101 

 

Try this:

let
    //get today's date relative to the user's timezone. Note: PBI Service uses UTC
    TodaysDate = Date.From(DateTime.From(DateTimeZone.RemoveZone(DateTimeZone.UtcNow()) + #duration(0,8,0,0))),
    StartDate = Date.AddMonths(TodaysDate,-26),
    //creates a list of numbers from the number of equivalent of StartDate to TodaysDate and then transform the list to dates
    Dates = List.Transform( {Number.From(StartDate)..Number.From(TodaysDate)}, Date.From),
    #"Converted to Table" = Table.FromList(Dates, Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error),
    #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Date", type date}})
in
    #"Changed Type"

This takes into consideration that user's machine's timezone is different from that of PBI Service.

danextian_0-1742904176447.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
pankajnamekar25
Super User
Super User

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.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.