Date to Text column

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
This is for Excel Power Query: I need to add a new column to a table and I want to populate it using todays date hour and seconds (as text) and concatenate that with the "Index" column. I am trying to create a unique identifier that will never be repeated. I think this would be the best way. Open to other options as well.

Thank you very much for the help - new to power query.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Data", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each DateTime.LocalNow()),
    #"Inserted Merged Column" = Table.AddColumn(#"Added Custom", "ID", each Text.Combine({Text.From([Index], "en-US"), Text.From([Custom], "en-US")}, " - "), type text),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Merged Column",{"Index", "Custom"})
in
    #"Removed Columns"

Book1
ABCDEFG
1NameDataNameDataID
2Adam Ant12Adam Ant121 - 9/10/2021 11:37:19 AM
3Bruce Banner9Bruce Banner92 - 9/10/2021 11:37:19 AM
4Charlie Chaplin15Charlie Chaplin153 - 9/10/2021 11:37:19 AM
5Delta Dawn4Delta Dawn44 - 9/10/2021 11:37:19 AM
6Emilio Estevez13Emilio Estevez135 - 9/10/2021 11:37:19 AM
7Fannie Farmer14Fannie Farmer146 - 9/10/2021 11:37:19 AM
8Galileo Galilei1Galileo Galilei17 - 9/10/2021 11:37:19 AM
9Harry Houdini7Harry Houdini78 - 9/10/2021 11:37:19 AM
10Igor Ivanov11Igor Ivanov119 - 9/10/2021 11:37:19 AM
11Jonah Jameson5Jonah Jameson510 - 9/10/2021 11:37:19 AM
12Kris Kristofferson10Kris Kristofferson1011 - 9/10/2021 11:37:19 AM
13Lois Lane3Lois Lane312 - 9/10/2021 11:37:19 AM
14Micky Mantle16Micky Mantle1613 - 9/10/2021 11:37:19 AM
15Nick Nolte8Nick Nolte814 - 9/10/2021 11:37:19 AM
16Ozzy Osbourne6Ozzy Osbourne615 - 9/10/2021 11:37:19 AM
17Pol Pot2Pol Pot216 - 9/10/2021 11:37:19 AM
18
Sheet13
 
Upvote 0
Solution

Forum statistics

Threads
1,223,701
Messages
6,173,916
Members
452,538
Latest member
ralphtaylor466

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