Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi, everyone!
I am trying to rename Field A based on a Value in Field B using M. For example
Field A Field B
1 "Field C"
2 "Field C"
3 "Field C"
Automatically renames to the following
Field C Field B
1 "Field C"
2 "Field C"
3 "Field C"
I tried the following:
#"Renamed Columns" = Table.RenameColumns(#"Added Custom",{{"Custom", [Field B]{0}}})
However, it returned the following error:
"Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?"
Any help would be most appreciated! Scott
Solved! Go to Solution.
Hi @Anonymous
Yes. You may have a look at my sample file here.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJWitWJVjKCs4whrFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [A = _t, B = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", Int64.Type}, {"B", type text}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"A", #"Changed Type"[B]{0}}}) in #"Renamed Columns"
Regards,
Cherie
Hi @Anonymous
You may refer to below post. Show a sample as below:
https://community.powerbi.com/t5/Desktop/Dynamic-column-name-from-its-value/td-p/189442
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJWitWJVjKCs4whrFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [A = _t, B = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", Int64.Type}, {"B", type text}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"A", #"Changed Type"[B]{0}}}) in #"Renamed Columns"
Regards,
Cherie
Thanks for the help, but I do not think that is what I was looking for. That tells me how to rename a field based on a value in its own column. I am wondering if I can rename a field based on a value in a different column. Can I do so with the same design?
Hi @Anonymous
Yes. You may have a look at my sample file here.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJWitWJVjKCs4whrFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [A = _t, B = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", Int64.Type}, {"B", type text}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"A", #"Changed Type"[B]{0}}}) in #"Renamed Columns"
Regards,
Cherie
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |