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.
Please help with syntax guidance for the following M code:
= Table.TransformColumns( #"table" , { "column", each if Text.Length(_) = 4 then _ else Text.Combine( {"0",_} ) } )
Result: Expression.Error: A cyclic reference was encountered during evaluation.
In short, the "column" within "table" stores four digit numbers as text for IDs. However, some three digit IDs need a zero appended to the front of the string (e.g., 0123). The formula above is attempting to fix that.
Dozens of edits have brought me this far, so maybe it's conceptual at this point, rather than syntax?
Thank You!
Solved! Go to Solution.
Hi @GiveMeArrays - You could consider using Text.PadStart like this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI3VorViVYyNjExBTNMjYxNYSJg2sRIKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}),
#"Added to Column" = Table.TransformColumns(#"Changed Type", {{"Column1", each Text.PadStart( Text.From(_) ,4 , "0" ) , type text }})
in
#"Added to Column"
Hi @GiveMeArrays - You could consider using Text.PadStart like this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI3VorViVYyNjExBTNMjYxNYSJg2sRIKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}),
#"Added to Column" = Table.TransformColumns(#"Changed Type", {{"Column1", each Text.PadStart( Text.From(_) ,4 , "0" ) , type text }})
in
#"Added to Column"
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 |
---|---|
102 | |
53 | |
21 | |
12 | |
12 |