Forum Discussion
adni85
4 years agoFrequent Visitor
Replace N/A value with non-null value in same column
Hi I am quite new to the power BI world and stuck with this issue. So as shown in table below, I have few N/A values in 'City' column. I want to replace N/A with the value based on the ...
- Anonymous4 years ago
Hi adni85 ,
Below is the full M syntax that you could paste in Advanced Editor:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVtJRMtQ31DcyMDICMsMS85LzS8tSi5RidaKVXN3cUaVD8ovy80rywZIRkVGokn6p5ZX5RdkoOo3gkvqOKBLG2IyEOccYXRfMLmNsdgWGu2LXBZMwgUk4pWZmZealK8XGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, Dates = _t, City = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Dates", type date}, {"City", type text}}), #"Replaced Value" = Table.ReplaceValue(#"Changed Type","N/A",null,Replacer.ReplaceValue,{"City"}), #"Sorted Rows" = Table.Sort(#"Replaced Value",{{"City", Order.Descending}}), #"Group" = Table.Group(#"Sorted Rows", {"Customer"}, {{"All_Rows", each Table.FillDown(_,{"City"}), type table}}), #"Expanded All_Rows" = Table.ExpandTableColumn(Group, "All_Rows", {"Dates", "City"}, {"Dates", "City"}), #"Changed Type1" = Table.TransformColumnTypes(#"Expanded All_Rows",{{"Dates", type date}}) in #"Changed Type1"Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
4 years agoNot applicable
Hi adni85 ,
Below is the full M syntax that you could paste in Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVtJRMtQ31DcyMDICMsMS85LzS8tSi5RidaKVXN3cUaVD8ovy80rywZIRkVGokn6p5ZX5RdkoOo3gkvqOKBLG2IyEOccYXRfMLmNsdgWGu2LXBZMwgUk4pWZmZealK8XGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, Dates = _t, City = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Dates", type date}, {"City", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","N/A",null,Replacer.ReplaceValue,{"City"}),
#"Sorted Rows" = Table.Sort(#"Replaced Value",{{"City", Order.Descending}}),
#"Group" = Table.Group(#"Sorted Rows", {"Customer"}, {{"All_Rows", each Table.FillDown(_,{"City"}), type table}}),
#"Expanded All_Rows" = Table.ExpandTableColumn(Group, "All_Rows", {"Dates", "City"}, {"Dates", "City"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded All_Rows",{{"Dates", type date}})
in
#"Changed Type1"
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.