Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi all,
I'd like to know if there's a way in M to generate a random sequence of numbers of predefined lenght in each row
I need this because I'm creating a demo of a report and I'd like to add the phone number of the users in a table but I have to randomly generate it as I cannot show real people telephone numbers
Therefore the requirement is to generate, in each row, a random sequence of 8 numbers, with as less effort as possible
Thanks
Solved! Go to Solution.
here it is with effort zero (from you 😁)
let
telnum= (digits,seed) =>Text.Combine(List.Transform(List.Random(digits,seed), each Text.From(Number.RoundDown(_*10)))),
lst=List.Transform({1..20}, each telnum(8,_) )
in
lst
Hi, @Anonymous
You may try what is suggested by @Anonymous . I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Here is the codes in 'Advanced Editor'.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzmDSBUy6KsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
temp = (digits,seed) =>Text.Combine(List.Transform(List.Random(digits,seed), each Text.From(Number.RoundDown(_*10)))),
#"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each List.Transform({1..20}, each temp(8,_)){[Index]}),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
#"Removed Columns"
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
You may try what is suggested by @Anonymous . I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Here is the codes in 'Advanced Editor'.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzmDSBUy6KsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
temp = (digits,seed) =>Text.Combine(List.Transform(List.Random(digits,seed), each Text.From(Number.RoundDown(_*10)))),
#"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each List.Transform({1..20}, each temp(8,_)){[Index]}),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
#"Removed Columns"
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
here it is with effort zero (from you 😁)
let
telnum= (digits,seed) =>Text.Combine(List.Transform(List.Random(digits,seed), each Text.From(Number.RoundDown(_*10)))),
lst=List.Transform({1..20}, each telnum(8,_) )
in
lst
=Number.RandomBetween()
https://docs.microsoft.com/en-us/powerquery-m/number-randombetween
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.