Forum Discussion
Anonymous
7 years agoNot applicable
PowerQuery: Renaming fields
In column B you see that there is Beer, Pop and Water. In PowerQuery, how do I change this to a new value called "Beverages" ?
I filtered for Beer, Pop, Water and replaced the value manually with Beverages but I can't unfilter the result to retrieve the other values. What is the proper way to do this?
Anonymous
Here is one way of doing it
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], Replacements = [ Beer = "Beverages", Pop = "Beverages", Water = "Beverages"], Replaced = Table.TransformColumns(Source, {{"Category", each Record.FieldOrDefault(Replacements, _, _)}}) in Replaced
8 Replies
- Zubair_MuhammadCommunity Champion
Anonymous
Here is one way of doing it
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], Replacements = [ Beer = "Beverages", Pop = "Beverages", Water = "Beverages"], Replaced = Table.TransformColumns(Source, {{"Category", each Record.FieldOrDefault(Replacements, _, _)}}) in Replaced- AnonymousNot applicable
(Replacements, _, _)
What replaces the underscore?
- Zubair_MuhammadCommunity Champion
Anonymous
No need to replace underscore _ :smileywink:
See the attached Excel file with your sample data and Power Query renaming