Forum Discussion
MAVIE
4 years agoHelper I
Dynamically Rename to ID column if ID column is missing
Hello Everyone, From sharepoint, I am getting a series of lookup columns which have the following format: ApplicationId Application ServerId Server EnvironmentId Environment ...
- 4 years ago
Use below code. ListOfColumns is that list which needs to be populated. You can also keep this list in a separate list query and replace ListOfColumns by your list.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAeOg1OT8ohQoRyk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Application = _t, ServerId = _t, Server = _t, Environment = _t, abc = _t]), ListOfColumns = {"Application", "abc", "Server"}, Custom1 = Table.TransformColumnNames(Source,(x)=>if List.Contains(ListOfColumns,x) then if List.Contains(Table.ColumnNames(Source),x&"Id") then x else x&"Id" else x) in Custom1
Vijay_A_Verma
4 years agoMost Valuable Professional
Use below code. ListOfColumns is that list which needs to be populated. You can also keep this list in a separate list query and replace ListOfColumns by your list.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAeOg1OT8ohQoRyk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Application = _t, ServerId = _t, Server = _t, Environment = _t, abc = _t]),
ListOfColumns = {"Application", "abc", "Server"},
Custom1 = Table.TransformColumnNames(Source,(x)=>if List.Contains(ListOfColumns,x) then if List.Contains(Table.ColumnNames(Source),x&"Id") then x else x&"Id" else x)
in
Custom1MAVIE
4 years agoHelper I
That seems to do the trick. Thank you very much for your help!