Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Assigning random value from reference table

tjamal1
8 - Asteroid

Hello , 

I have reference table which contains category and their max and min value

Category MinMax
A1015
B1620
C2125

 

I have another table which contains user category and his ID 

I want to assign random value to him based on his category max and min value 

User 

CategoryValue 
1A 
2A 
3B 
4C 
5C 

 

Value should be between max and min value of his category 

 

 

Is there anyway to do it ?

8 REPLIES 8
WilliamR
Alteryx
Alteryx

Hi @tjamal1 ,

using the RandInt function, it should do what you want.

 

WilliamR_0-1577969546074.png

 

(If this post helps, then please consider it as the solution to help the other members find it more quickly).

tjamal1
8 - Asteroid

Thanks for the reply

can you briefly explain , whats the logic for this formula?

danilang
19 - Altair
19 - Altair

Hi @tjamal1 

 

You can do this by joining on the category and then using 

[Min]+randint([max]-[Min])

giving you

 

r.png 

 

Dan

tjamal1
8 - Asteroid

Thanks for the reply 

does it work for decimal values ? 

WilliamR
Alteryx
Alteryx

Yes, consider this option depending on the number of decimal you want:

WilliamR_1-1577970089816.png

 

RandInt([Max]*10000-[Min]*10000)/10000 + [Min]

The formula generate a random number in range of Max-Min where you add Min to get what you want.

Don't forget to modify the type of the column to double.

(If this post helps, then please consider it as the solution to help the other members find it more quickly).

danilang
19 - Altair
19 - Altair

Hi @tjamal1 

 

This will only add a integer value to the min.  To add a decimal in the range use

 

[Min]+ Rand()*([Max]-[Min])

 

Rand() returns a real number between 0 and 1.  Multiply this by the total range and add [min] to give your final value

 

Dan

tjamal1
8 - Asteroid

Will it work for 

  Min            Max

0.61.3

   Min           Max

0.6100

 

danilang
19 - Altair
19 - Altair

Hi @tjamal1 

 

Yes it will

 

r2.png

 

Dan 

Labels