Forum Discussion
Creating a Date Table with only months
- Anonymous3 years ago
Hi Anonymous
You can refer to the following example.
Create a new table
Table = var a=ADDCOLUMNS(CALENDAR(DATE(2022,1,1),DATE(2023,1,1)),"Month Year",FORMAT([Date],"yyyy mmmm")) return SUMMARIZE(a,[Month Year])Then change the data type to date, and the format to "mmmm yyyy"
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
You can create a blank query and paste this code to generate desired results.
Please change the range as per your requirement.
----------------------------------
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDRQio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [StartDate = _t]),
#"Changed column type" = Table.TransformColumnTypes(Source, {{"StartDate", type date}}),
#"Added custom" = Table.AddColumn(#"Changed column type", "EndDate", each "12/31/2025"),
#"Changed column type 1" = Table.TransformColumnTypes(#"Added custom", {{"EndDate", type date}}),
#"Added custom 1" = Table.AddColumn(#"Changed column type 1", "Date", each {Number.From([StartDate])..Number.From([EndDate])}),
#"Expanded Date" = Table.ExpandListColumn(#"Added custom 1", "Date"),
#"Changed column type 2" = Table.TransformColumnTypes(#"Expanded Date", {{"Date", type date}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed column type 2",{"StartDate", "EndDate"}),
#"Calculated Start of Month" = Table.TransformColumns(#"Removed Columns",{{"Date", Date.StartOfMonth, type date}}),
#"Removed Duplicates" = Table.Distinct(#"Calculated Start of Month")
in
#"Removed Duplicates"