Skip to content

Instantly share code, notes, and snippets.

@ncalm
Created November 22, 2022 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncalm/063f0c551dcabe5483ee07fbafdb2c88 to your computer and use it in GitHub Desktop.
Save ncalm/063f0c551dcabe5483ee07fbafdb2c88 to your computer and use it in GitHub Desktop.
Custom function to convert full names like "First Middle Last" to "F.M. Last"
(
table as table,
column_name as text,
new_column_name as text
) as table =>
Table.AddColumn(
table,
new_column_name,
each
let
Names = Text.Split( Record.Field(_,column_name) , " " ),
Initials = List.Transform( Names , each Text.Start(_,1) & "." ),
FirstMiddle = Text.Combine( List.RemoveLastN( Initials , 1 ) )
in
FirstMiddle & " " & List.Last( Names )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment