Arcade is excellent. I'm digging in and using it alot. But one of the things I am finding a need for is to generate random numbers. I build a lot of demo maps with fake data. I have to generate fake budgets, fake dates, etc. I generally just 'lorem ipsum' for descriptions but I need to be able to better generate more (close to) realistic numbers.
Does anyone know how I could do this with Arcade?
My preference would be Random(x) to get a number between 0 and X. But that isn't to be.
Anyone?
Solved! Go to Solution.
Since Random (Math Functions | ArcGIS for Developers ) returns a value between 0 and 1 you just multiply with the value you want to use as upper boundary:
Random() * X
If you want a value between A and B, you can do this:
Random() * (B - A) + A
Since Random (Math Functions | ArcGIS for Developers ) returns a value between 0 and 1 you just multiply with the value you want to use as upper boundary:
Random() * X
If you want a value between A and B, you can do this:
Random() * (B - A) + A
This works, but how can one get it to work by generating whole numbers? Currently, this is set up to produce floats or doubles.
You can use Round() and set it to 0 to return whole numbers i.e. Round(x,0)
Hello @Sarah_Saint-Ruth @XanderBakker
I need to create new field with unique ID for hosted layer which already published in AGOL. I can't find any Arcade code for creating unique ID for new field in AGOL . I am thinking about to copy object id to new field but I don't know the arcade code for it.
I will appreciate any help