PowerQuery Calendar Table

gavs73

Board Regular
Joined
Apr 22, 2008
Messages
138
Hi

I have an Automated Caldendar table, using the M Code below, is there a way to change it so that it goes up in increments of 1 Month rather than by Day ?

= List.Dates(Source, Number.From(DateTime.LocalNow())-Number.From(Source),#duration(1,0,0,0))

Thanks for your help.

Gav
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Gav

Do you only want to display the month and year?

Perhaps List.Transform with Date.ToText might help.

VBA Code:
= List.Transform(List.Dates(Source, Number.From(DateTime.LocalNow())-Number.From(Source),#duration(30,0,0,0)), each Date.ToText(_, "MMMM-yyyy))
 
Upvote 0
Gav

Do you only want to display the month and year?

Perhaps List.Transform with Date.ToText might help.

VBA Code:
= List.Transform(List.Dates(Source, Number.From(DateTime.LocalNow())-Number.From(Source),#duration(30,0,0,0)), each Date.ToText(_, "MMMM-yyyy))

Hi thanks for your reply, instead of the returning individual days between my start date 01/01/2021 and Today, I just need the Month, so as at Today I'd only have 3 rows for January, February, March. Instead of 60+ rows that i currently have for days.
 
Upvote 0
What I posted will only return months - note the change in #duration.

If all you want is the month name change "MMMM yyyy" to "MMMM".
 
Upvote 0

Forum statistics

Threads
1,223,728
Messages
6,174,150
Members
452,548
Latest member
Enice Anaelle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top