Blank Values while using Random(a,b) function in formula field

Hey ,

I need to create values of a certain field based on the values of another field in the same data set. I am trying to use the random function to generate a numerical value. However this ends up creating a dataset with a lot of blank values for that field

Here is the formula I am using :
if field(‘Type’) == ‘Road’ then random(500000,5000000) else end

Not quite sure how to prevent creation of null values in the dataset.

You need to specify the value that should be output when Type is not “Road” between else and end in your formula. If you need to specify values for other types you can do so with something like:

if field('Type') == 'Road' then random(500000,5000000) elsif field('Type') == 'Bridge' then random(1000,10000) end

I’m trying to create a similar formula.

You need “elsif” instead of “elseif” because Ruby :slight_smile: