Alteryx Designer Desktop Discussions

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

Generating a RANDINT that is less than an existing variable - in this case a median value

MMM
5 - Atom

Hello all,

 

I am working to build a formula that generates a RANDOM INTEGER > 1 but less than the MEDIAN VALUE OF A VARIABLE (the new value would have a range of 1 to the MEDIAN VALUE which changes depending on the country- all Median values are >1) – any thoughts as to how to write this?

 

Example below:

IF ([D10b_2_Savings_account_s_total_curent_balance__all_savings]>[Median_D10b_2_Savings_account_s_total_curent_balance__all_savings]) THEN

 

RAND (1,[Median_D10b_2_Savings_account_s_total_curent_balance__all_savings])

 

ELSE [D10b_2_Savings_account_s_total_curent_balance__all_savings]

 

ENDIF

 

3 REPLIES 3
MarqueeCrew
20 - Arcturus
20 - Arcturus
I would suggest using a summarize tool to calculate the median value and then using an append fields tool to add that value to your data. Now you can use the randint(median) as your formula.

Cheers,
Mark

Sent from my iPhone
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
NickC
Alteryx Alumni (Retired)

Hello MMM,

 

Please have a look at the workflow I have created for this. RANDINT will enable you to include a maximum field whereas RAND just produces a number between 0 and 1.

 

 

24-04-2017 13-17-10.png

 

 

 

Hope this helps.

 

Nick

 

 

MMM
5 - Atom

Many thanks - this worked!

Labels