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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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,215,432
Messages
6,124,858
Members
449,194
Latest member
HellScout

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