Forum Discussion
Non volatile random numbers between
- 2 months ago
You are missing the +min at the end to make it start from 97. If you run yours, the numbers won't start from min. Check the one I have shared for ten values (Count):
If this is not what you are looking for, please describe the ouput you are imaging for the function.
Regards
Hi. Do you mean a list of random that even after a refresh will keep same values?
You could build it like the following code, specifying a seed to make it deterministic. Add a New blank query and create the function, you can call it getRandom:
(min as number, max as number, count as number, seed as number) =>
let
range = max - min + 1,
rnd =
List.Transform(
List.Random(count, seed),
each Number.IntegerDivide(_ * range, 1) + min
)
in
rnd
Then you can call it any where, for example using your nros as example:
getRandom(97,122,100,1)
That would generate 100 estable numbers between 97 and 122.
I hope that helps,
- Dicken2 months agoPost Prodigy
Not sure i get this ;
let range = max - min + 1, rnd = List.Transform( List.Random(count, seed), each Number.IntegerDivide(_ * range, 1) + min ) in rndit does not seem very different to what I posted, and haveing tried, i still have a range starting at 0 ,
can you show an actual example, where a random list stable List is produced between a min andn max valess say 10 an 20 ? I have tried the abvoelet range = (122 - 97)+1 in List.Transform( List.Random( 20, 1) , (x)=> Number.IntegerDivide( x * range , 1) )and it just takes gvies range of 1 - 26 ?
Richard.- ibarrau2 months agoSuper User
You are missing the +min at the end to make it start from 97. If you run yours, the numbers won't start from min. Check the one I have shared for ten values (Count):
If this is not what you are looking for, please describe the ouput you are imaging for the function.
Regards
- Dicken2 months agoPost Prodigy
Thanks, think i've got it;
let
acount = 20,
max = 20 ,
min = 10 ,
range = (max - min) +1 ,
rnd =
List.Transform(
List.Random( acount , 1 ),
each Number.IntegerDivide(_ * range, 1) + min
)
in
rnd
Just trying to get the logic, i see it and then it slips away 😊