Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello,
I just found a mistake in my table after uploading it to POwer BI Desktop. I had 2 columns one with "Country" and other "Region".
Where portugal in the country column is by mistake coded as In Middle East & Africa in the region column. How to change it?
I went to Power Query and filtered portugal in the country and did replace value then it worked. But couldn't remove the filer. Can someone help...
Solved! Go to Solution.
Hi @yemara ,
Can you please attach a screenshot to show exactly where the problem is occurring? I'm having a hard time determining what the problem is just from the description.
Alternatively, I can provide you with a workaround. you can create a custom column to fix the Region column in Power Query using the following solution:
You can then delete the original Region column and use the newly created custom column as the Region.
Here is the M code in Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKsgvKilNT8xR0lHyzUxJyUlVcE0sLlGK1UGRckwrykxORBd1LS3KL0gFi4Z6o/Jd0ysLSrCY6ZtflJ+cnI9kZCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, Region = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Country", type text}, {"Region", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Country] = "portugal" then "Europe" else [Region])
in
#"Added Custom"
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @yemara, you can replace values with conditions (great article by @RickdeGroot you can find here)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCsgvKilNT8xR0lHyzUxJyUlVcE0sLlGK1UGRckwrykxORBd1LS3KL0gFi4Z6o/Jd0ysLSrCY6ZtflJ+cnI9kZCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, Region = _t]),
Replace = Table.ReplaceValue(
Source,
each [Country], // y in (x,y,z)
each "Europe", // z in (x,y,z)
(x,y,z)=> if Text.Contains(y, "portugal", Comparer.OrdinalIgnoreCase) then z else x, // x means do not change value (or change it to value itself)
{"Region"} //here you can define in which columns should have beed replacement performed i.e. you can try change {"Region"} to {"Country", "Region"} or just to {"Conutry"}
)
in
Replace
Hi @yemara, you can replace values with conditions (great article by @RickdeGroot you can find here)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCsgvKilNT8xR0lHyzUxJyUlVcE0sLlGK1UGRckwrykxORBd1LS3KL0gFi4Z6o/Jd0ysLSrCY6ZtflJ+cnI9kZCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, Region = _t]),
Replace = Table.ReplaceValue(
Source,
each [Country], // y in (x,y,z)
each "Europe", // z in (x,y,z)
(x,y,z)=> if Text.Contains(y, "portugal", Comparer.OrdinalIgnoreCase) then z else x, // x means do not change value (or change it to value itself)
{"Region"} //here you can define in which columns should have beed replacement performed i.e. you can try change {"Region"} to {"Country", "Region"} or just to {"Conutry"}
)
in
Replace
Hi @yemara ,
Can you please attach a screenshot to show exactly where the problem is occurring? I'm having a hard time determining what the problem is just from the description.
Alternatively, I can provide you with a workaround. you can create a custom column to fix the Region column in Power Query using the following solution:
You can then delete the original Region column and use the newly created custom column as the Region.
Here is the M code in Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKsgvKilNT8xR0lHyzUxJyUlVcE0sLlGK1UGRckwrykxORBd1LS3KL0gFi4Z6o/Jd0ysLSrCY6ZtflJ+cnI9kZCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, Region = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Country", type text}, {"Region", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Country] = "portugal" then "Europe" else [Region])
in
#"Added Custom"
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @yemara
If you want to remove just the filter, click the "X" next to the filter step in the Applied Steps pane. This should remove only the filtering action and retain all other steps (including your replace value action).
Proud to be a Super User!
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
27 | |
17 | |
11 | |
9 | |
6 |
User | Count |
---|---|
47 | |
30 | |
21 | |
18 | |
11 |