Forum Discussion
Asamadi
Helper I
9 years agoCustom Column Randbetween
I want to Create a Custom column ( Query Editor Environment) and generate random Numbers between for example 500 to 1000. I have tried this formula: Number.RandomBetween(500,1000) but it create...
- 9 years ago
I found the solution:
If i add Index Column the formula works correct.
MarcelBeug
Community Champion
9 years agoIn such cases I would use another number column, like in:
let
Source = Table.FromColumns({List.Numbers(0,20,1)},type table[Number = Int64.Type]),
#"Added Custom" = Table.AddColumn(Source, "Random", each Number.RandomBetween(500+[Number]-[Number],1000))
in
#"Added Custom"The part [Number]-[Number] forces recalculation of the random number for each row. You can use any number column for this.
MarcelBeug
Community Champion
9 years agoAlternatively and similarly you can create a (temporary) column with the lower limit value in each row.
let
Source = Table.FromColumns({List.Numbers(500,20,0)},type table[NumberFrom = Int64.Type]),
#"Added Custom" = Table.AddColumn(Source, "Random", each Number.RandomBetween([NumberFrom],1000))
in
#"Added Custom"