Forum Discussion
Non volatile random numbers between
Hi,
is there a way to create a stablel random list bwtween, two numbers; so a staable list 1 to 10 could be
= List.Transform(
List.Random( 20,1), (x)=>
Number.IntegerDivide( ( x * 10 ) ,1 )
) the problem is this method always starts at 1 and i would like to cntrol the min and max vaulues,
what i woud like is stable version of
List.Transform( {1..100},(x)=>
let n =
Number.IntegerDivide( Number.RandomBetween( 97, 122),1)
in
Character.FromNumber(n) ) any suggestions,
Richard.
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
5 Replies
- ibarrauSuper User
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 rndThen 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,
- DickenPost 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.- ibarrauSuper 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
- anilelmastasiSuper User
Hello Dicken ,
Can you try List.Random function?
You can check this.
If this solved your issue, please mark it as the accepted solution. ✅