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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Imthedan
Helper II
Helper II

Generating Rolling Calendar Lookup Table with TODAY as middle date.

Hello,

I need to generate a rolling calendar lookup table (that I need to add columns to) where today would be the middle date. Ideally, it would be 90 days before today and 30 days in the future.

 

I was helped on here the other day with creating a rolling 90 day calendar, but I wasn't able to pick through the code to add the future 30 days as well.

 

let
    Source = 
    {
        Number.From(Date.AddDays(DateTime.Date(DateTime.LocalNow()), -90))..
        Number.From(DateTime.Date(DateTime.LocalNow()))
    },
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error),
    #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Date", type date}})
in
    #"Changed Type"

 

Any help is appreciated!

 

1 ACCEPTED SOLUTION
FrankAT
Community Champion
Community Champion

Hi @Imthedan 

use the following M-Code:

 

// DateRange
let
    Source = 
    {Number.From(Date.AddDays(DateTime.Date(DateTime.LocalNow()), -90))..
    Number.From(Date.AddDays(DateTime.Date(DateTime.LocalNow()), 30))
},
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error),
    #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Date", type date}})
in
    #"Changed Type"

 

Regards FrankAT

View solution in original post

2 REPLIES 2
FrankAT
Community Champion
Community Champion

Hi @Imthedan 

use the following M-Code:

 

// DateRange
let
    Source = 
    {Number.From(Date.AddDays(DateTime.Date(DateTime.LocalNow()), -90))..
    Number.From(Date.AddDays(DateTime.Date(DateTime.LocalNow()), 30))
},
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error),
    #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Date", type date}})
in
    #"Changed Type"

 

Regards FrankAT

Thank you!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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