Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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.
Solved! Go to Solution.
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.
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.
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.
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.
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.
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
57 | |
38 | |
36 |
User | Count |
---|---|
81 | |
67 | |
61 | |
46 | |
45 |