Forum Discussion
create date value for each row in a table
- 5 years ago
Create a new Blank Query with
= List.Dates(#date(2021,01,01), 365, #duration(1,0,0,0))That will give you a list of dates. Give it a name.
Convert to table.
Change to date type.
Filter the dates with :
= Table.SelectRows(#"Changed Type", each Date.Day([Column1]) = 1)
(substitute your step name and column name in that)
---
In the original table, Add a custom column (type # and the name of the query should autocomplete)
Then expand the column from the column header.
Good luck
- 5 years ago
Hello Zabeer
add a new column with this formula
List.Transform(List.Numbers(1,12), each #date(2021,_,1))and then expand the list-column to new rows. Here the complete example
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI2MzAwUIrViVZyAvJMLMC8WAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Value", Int64.Type}}), AddMonths = Table.AddColumn ( #"Changed Type", "MonthsList", each List.Transform(List.Numbers(1,12), each #date(2021,_,1)) ), #"Expanded MonthsList" = Table.ExpandListColumn(AddMonths, "MonthsList") in #"Expanded MonthsList"this transforms this
into this
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy - 5 years ago
Hi Zabeer ,
If you also want to add each days of each months, please try this:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI2MzAwUIrViVZyAvJMLMC8WAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Value", Int64.Type}}), AddDays = Table.AddColumn(#"Changed Type", "DaysList", each let StartDate = #date(2021,01,01), EndDate = #date(2021,12,31), DurationDays = Duration.Days( EndDate-StartDate) in List.Dates(StartDate, DurationDays, #duration(1,0,0,0))), #"Expanded DaysList" = Table.ExpandListColumn(AddDays, "DaysList") in #"Expanded DaysList"Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Create a new Blank Query with
= List.Dates(#date(2021,01,01), 365, #duration(1,0,0,0))
That will give you a list of dates. Give it a name.
Convert to table.
Change to date type.
Filter the dates with :
= Table.SelectRows(#"Changed Type", each Date.Day([Column1]) = 1)
(substitute your step name and column name in that)
---
In the original table, Add a custom column (type # and the name of the query should autocomplete)
Then expand the column from the column header.
Good luck