Forum Discussion
Anonymous
2 years agoNot applicable
Dynamic column name based on a column value coming from a different unrelated table
Hi, I have a requirement to get the column name (for Table A) that can change dynamically based on column value that is coming from a different table (Table B) which is not related to this table ...
Anonymous
2 years agoNot applicable
Hi Anonymous ,
Please try:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RY85DoAwDAT/4prC3LSEMomUkkNpQIIe+L9YCE6mWEujabws1DPnlFGvBmzOzDi3QD77igJynGZsGYpDkKKEVEqlYhOkqCC11tgmFGtEkhrWGIOtQ3JFJGlgnXPYLiTnjwQtnLX2f+Yt9gR5/wA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", Int64.Type}, {"Column4", type text}}),
Custom1 = Table.FromList(Table.ColumnNames(#"Changed Type")),
#"Merged Queries" = Table.NestedJoin(Custom1, {"Column1"}, TableB, {"Column Name"}, "TableB", JoinKind.LeftOuter),
#"Expanded TableB" = Table.ExpandTableColumn(#"Merged Queries", "TableB", {"Extract Date"}, {"Extract Date"}),
#"Added Custom" = Table.AddColumn(#"Expanded TableB", "Names", each [Column1] & " - " & [Extract Date]),
Custom2 = Table.Group(#"Changed Type",{"Column1"},{{"Data",each _}}),
#"Expanded Data" = Table.ExpandTableColumn(Custom2, "Data", {"Column1", "Column2", "Column3", "Column4"}, #"Added Custom"[Names]),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Data",{"Column1"})
in
#"Removed Columns"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group