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,
I need to replace null values in a column with unique values that are some combination of text and a incrementing number (for example "Some code 1", "Some code 2"). Main problem that I have is that all values in this column have to be unique so null values need to replaced with unique values.
Thank you.
Solved! Go to Solution.
@Anonymous ,
Try this mcode:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs7PTVVIzk9JVTBUitWJVgITCEEjbILGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"Column1"}),
#"Grouped Rows" = Table.Group(#"Replaced Value", {"Column1"}, {{"Rows", each if _[Column1]{0} = null then Table.AddIndexColumn(_, "Index", 1,1) else _, type table}}),
#"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"Rows"}),
#"Expanded Rows" = Table.ExpandTableColumn(#"Removed Other Columns", "Rows", {"Column1", "Index"}, {"Column1", "Index"}),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Expanded Rows", {{"Index", type text}}, "pt-BR"),{"Column1", "Index"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")
in
#"Merged Columns"
Also, check the attached file.
@Anonymous ,
Try this mcode:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs7PTVVIzk9JVTBUitWJVgITCEEjbILGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"Column1"}),
#"Grouped Rows" = Table.Group(#"Replaced Value", {"Column1"}, {{"Rows", each if _[Column1]{0} = null then Table.AddIndexColumn(_, "Index", 1,1) else _, type table}}),
#"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"Rows"}),
#"Expanded Rows" = Table.ExpandTableColumn(#"Removed Other Columns", "Rows", {"Column1", "Index"}, {"Column1", "Index"}),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Expanded Rows", {{"Index", type text}}, "pt-BR"),{"Column1", "Index"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")
in
#"Merged Columns"
Also, check the attached file.
@Anonymous , you can create an index column starting with a very big number, when code 1, 2 will not reach and then replace null with code & [index]
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 |
---|---|
111 | |
95 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |