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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ElliotP
Post Prodigy
Post Prodigy

Date Table, Powerquery to Future Set Date

Evening,

 

I've follow the guides to setup a Date Table using powerquery and it works perfectly.

 

let
    Source = #date(2010, 1, 1),
    Custom1 = List.Dates(Source, Number.From(DateTime.LocalNow())- Number.From(Source) ,#duration(1,0,0,0)),
    #"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

I was wondering how to change it from simply creating the DateTable "DateTime.LocalNow()" until today, but until say for example the 1/1/2018 instead.

 

Thoughts on the powerquery code?

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

Just replace DateTime.LocalNow() by #date(2018,1,1).

 

Alternative code:

 

let
    Source = Table.FromColumns({{Number.From(#date(2017,1,1))..Number.From(#date(2018,1,1))}}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}})
in
    #"Changed Type"
Specializing in Power Query Formula Language (M)

View solution in original post

1 REPLY 1
MarcelBeug
Community Champion
Community Champion

Just replace DateTime.LocalNow() by #date(2018,1,1).

 

Alternative code:

 

let
    Source = Table.FromColumns({{Number.From(#date(2017,1,1))..Number.From(#date(2018,1,1))}}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}})
in
    #"Changed Type"
Specializing in Power Query Formula Language (M)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.