Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Help: Clean List as Record in Field?

I have a very simple table where I've converted a delimited string of text into a list contained in a record (see screen shots).

 

Text String

rpiboy1_2-1657115954238.png

Text String Converted to List

rpiboy1_0-1657113427879.png

When I select the list record to view it, there are "blanks" (which is expected).

rpiboy1_1-1657113481511.png

The quanitity of blanks will vary and the quantity of values may vary (less likely).

 

I was trying to write some M to dynamically clean the record list, so that in this example I would get it down to {13, 30}.

Here is the M I've written, it doesn't err out, but nor does it clean the list(s) for me... :-(.

I've also tried "" rather than " " to see if that would help and neither did anything.

let
    Source = #"SomeTable",
    #"Record to List" = Table.TransformColumns(Source, {"IdString", each Text.Split(_, ",")}),
    #"ReplaceValue" = Table.TransformColumns(#"Record to List", {"IdString", each List.ReplaceValue(_, " ", null, Replacer.ReplaceText)}),
    #"CleanNulls" = Table.TransformColumns(#"ReplaceValue", {"IdString", each List.RemoveNulls(_)})
in
    #"ReplaceValue"

 Suggestions much appreciated!

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("LYxRCsAwDEKvIvl2EGM36FlK73+NhW4ICu+Ba8WlzJq3gyETdDI2D5crszmh0QZ+flP+aArgieZZskYX+mK/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, IdString = _t]),
    Custom1 = Table.ReplaceValue(Source,each [IdString],each List.RemoveNulls(List.Transform(Text.Split([IdString],","),each try Number.From(_) otherwise null)),Replacer.ReplaceValue,{"IdString"})
in
    Custom1

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

That works! Now I just need to understand why/how and where I went wrong, since it seems like I was on the right track.

 

Thanks so much!

Your approach is also right but you need to capture the unicodes of blanks and replace those blanks (these blanks are called whitespace characters and they are also other than what is "" in Excel and here and not only limited to ""). Rather than taking this route, I decided to take reverse route. Rather than checking for blanks, just check for the presence of numbers and replace anything other than numbers with nulls. 

Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("LYxRCsAwDEKvIvl2EGM36FlK73+NhW4ICu+Ba8WlzJq3gyETdDI2D5crszmh0QZ+flP+aArgieZZskYX+mK/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, IdString = _t]),
    Custom1 = Table.ReplaceValue(Source,each [IdString],each List.RemoveNulls(List.Transform(Text.Split([IdString],","),each try Number.From(_) otherwise null)),Replacer.ReplaceValue,{"IdString"})
in
    Custom1

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.