Forum

Dynamic Date Table
 
Notifications
Clear all

Dynamic Date Table

4 Posts
2 Users
0 Reactions
151 Views
(@vivianzhou_1999yahoo-com)
Posts: 7
Active Member
Topic starter
 

Hi, I wanted to create a table with a list of dynamic dates from 1st January 2019. My query formula is below but it has errors. Can you please correct them?

Source = #table( type table [Dates=date],{List.Dates(#date(2019, 1, 1), Duration.Days(DateTime.Date(DateTime.FixedLocalNow())-#date(2018,12,31)), #duration(1, 0, 0, 0))}),

Thanks a lot!

Vivian

 
Posted : 08/01/2020 11:48 am
(@gue19)
Posts: 8
Active Member
 

Hi Vivian,

 

why are you not using

let
  #"Start Date" = #date(2019, 1, 1),
  Source = List.Dates(#"Start Date", Duration.Days(DateTime.Date(DateTime.FixedLocalNow())-#"Start Date")+1, #duration(1, 0, 0, 0)),
  #"Calendar Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
  #"Calendar Table"

 

best regards,

Guenter

 
Posted : 08/01/2020 12:35 pm
(@gue19)
Posts: 8
Active Member
 

you missed a bracket 🙂

 

Source = #table( type table [Dates=date],{{List.Dates(#date(2019, 1, 1), Duration.Days(DateTime.Date(DateTime.FixedLocalNow())-#date(2018,12,31)), #duration(1, 0, 0, 0))}}),

 

the function expects a single element (list) instead of already all dates (expanded list)

cheers,

Guenter

 
Posted : 08/01/2020 6:26 pm
(@vivianzhou_1999yahoo-com)
Posts: 7
Active Member
Topic starter
 

Hi Guenter

Thank you for your replies. Your formula in your above post 2 works and many thanks to you!

Re the amended formula in your post 3, it got rid of the orginal errors but the table does not generate the list of dates as I thought it would. Do you know why? I am very new to the M language...

Cheers,

Vivian

 
Posted : 09/01/2020 4:30 pm
Share: