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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Add new row as datetime using Power Query

I'm trying to add new rows to a dataset which I get using power query, but I don't know the right way to add datetimes.

This is my query:

 

 

#"New Rows" = Table.InsertRows(#"Filtered Rows",Table.RowCount(#"Filtered Rows"),{[codunidade = 1435883] , [codunidade = 918465] , [codunidade = 1435885]})

 

 

I'd like to insert a specific datetime for each row. Something like this:

 

 

#"New Rows" = Table.InsertRows(#"Filtered Rows",Table.RowCount(#"Filtered Rows"),{[codunidade = 1435883, date = "2021-12-31T23:59:59"] , [codunidade = 918465, date = "2021-12-31T23:59:59"] , [codunidade = 1435885, date = "2021-12-31T23:59:59"]})

 

 

How could I do that?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Not quite sure what you are looking for. Do you want to add a column with a specific date for each row or add multiple rows with a specific date? Could you please provide some raw example data and the final table data you want? I have created a sample file(see attachment) for you, please check if it is the result you want...

Situation 1. Insert rows

yingyinr_0-1641265523317.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddBLCsAgDATQqxTXgmbyUXsV8f7XaKkRulDIbt5iJr0HkmLCOcRASJCEDLrAt7b3wohLkAs9Criwo2AX5SjERd0KNsXq0bYCrVqZgvNWiJbqa5m2Qg3zH+nL8cvHAw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [codunidade = _t, date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"codunidade", Int64.Type}, {"date", type datetime}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [date] = #datetime(2021, 12, 31, 23, 59, 59)),
    #"New Rows" = Table.InsertRows(#"Filtered Rows",Table.RowCount(#"Filtered Rows"),{[codunidade = 1435883, date = DateTime.FromText("2021-12-31T23:59:59")] , [codunidade = 918465, date = DateTime.FromText("2021-12-31T23:59:59")] , [codunidade = 1435885, date = DateTime.FromText("2021-12-31T23:59:59")]})
in
    #"New Rows"

Situation 2. add date column

yingyinr_1-1641265642595.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc7JDQAhDAPAXvLmkYsctSD6b2PJCqR8R7bltYDUTQVhQBjs8YAOEGITPpLRQA44NdAayQtik2sk5QJnmFfiVXR6YIdp/B+pyv4A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [codunidade = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"codunidade", Int64.Type}, {"Sales", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Sales] >= 90),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each DateTime.FromText("2021-12-31T23:59:59"))
in
    #"Added Custom"

Best Regards

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hey guys, thank you for all the answers.

Was just missing the right function: 

 

DateTime.FromText( )

 

Anonymous
Not applicable

Hi @Anonymous ,

Not quite sure what you are looking for. Do you want to add a column with a specific date for each row or add multiple rows with a specific date? Could you please provide some raw example data and the final table data you want? I have created a sample file(see attachment) for you, please check if it is the result you want...

Situation 1. Insert rows

yingyinr_0-1641265523317.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddBLCsAgDATQqxTXgmbyUXsV8f7XaKkRulDIbt5iJr0HkmLCOcRASJCEDLrAt7b3wohLkAs9Criwo2AX5SjERd0KNsXq0bYCrVqZgvNWiJbqa5m2Qg3zH+nL8cvHAw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [codunidade = _t, date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"codunidade", Int64.Type}, {"date", type datetime}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [date] = #datetime(2021, 12, 31, 23, 59, 59)),
    #"New Rows" = Table.InsertRows(#"Filtered Rows",Table.RowCount(#"Filtered Rows"),{[codunidade = 1435883, date = DateTime.FromText("2021-12-31T23:59:59")] , [codunidade = 918465, date = DateTime.FromText("2021-12-31T23:59:59")] , [codunidade = 1435885, date = DateTime.FromText("2021-12-31T23:59:59")]})
in
    #"New Rows"

Situation 2. add date column

yingyinr_1-1641265642595.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc7JDQAhDAPAXvLmkYsctSD6b2PJCqR8R7bltYDUTQVhQBjs8YAOEGITPpLRQA44NdAayQtik2sk5QJnmFfiVXR6YIdp/B+pyv4A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [codunidade = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"codunidade", Int64.Type}, {"Sales", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Sales] >= 90),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each DateTime.FromText("2021-12-31T23:59:59"))
in
    #"Added Custom"

Best Regards

Hi I have similar question: 

Every day I will get a total cost summary like this:

1. Day 1 - 09/15/2025

Total cost summary:

CategoryCost
Fruit120
Vegetable200
Meat350

 

After day 1, I want to have a table:

DateCategoryCost
09/15/2025Fruit120
09/15/2025Vegetable200
09/15/2025Meat350

 

2. Day-2 09/16/2025

Total cost summary:

CategoryCost
Fruit100
Vegetable250
Meat200

 

After day 2, I want to have a table:

DateCategoryCost
09/15/2025Fruit120
09/15/2025Vegetable200
09/15/2025Meat350
09/16/2025Fruit100
09/16/2025Vegetable250
09/16/2025Meat200

 

3. Day 3 09/17/2025

Total cost summary:

CategoryCost
Fruit150
Vegetable220
Meat300

 

After day 1, I want to have a table:

DateCategoryCost
09/15/2025Fruit120
09/15/2025Vegetable200
09/15/2025Meat350
09/16/2025Fruit100
09/16/2025Vegetable250
09/16/2025Meat200
09/17/2025Fruit150
09/17/2025Vegetable220
09/17/2025Meat300

 

Question: How can I add new rows to table with date?

sevenhills
Super User
Super User

Try DateTime.FromText ... 

date = DateTime.FromText("2021-12-31T23:59:59")

 

Sample in M Query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUUpMBJFGBkaGuoZGusaGIUbGVqaWQKQUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type datetime}}),
    #"New Rows" = Table.InsertRows(#"Changed Type", Table.RowCount(#"Changed Type"), {[Column1 = "b", Column2 = "bbb", Column3 = DateTime.FromText("2021-12-31T23:59:59") ], [Column1 = "c", Column2 = "ccc", Column3 = DateTime.FromText("2021-12-31T23:59:59")]})
in
    #"New Rows"

  

parry2k
Super User
Super User

@Anonymous what is the logic to add a date?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors