Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Selecting random records to achieve a specific average

FrankieChai
5 - Atom

Hi,

 

I have a file of 550,000 members along with their birth date and I need to randomly select 53,000 records from it.  The caveat is that I need the average age of these 53,000 records to be 53.  Is there a way I can do this in Alteryx?

 

Thank you

3 REPLIES 3
CharlieS
17 - Castor
17 - Castor

Here's how this could be done:

- First, calculate the difference in age that each member is from 53.

- After that is calculated, then you could randomly pair people together that average out to 53. For example, pair a 50 year old with a 56 year old.

- Now that the random pairs are generated, select 27,500 pairs (55,000 people) for the final output. 

 

This process would require some batch/iterative macros, but it's all very possible in Alteryx. 

benakesh
12 - Quasar

Hi @FrankieChai ,

This is interesting problem !

This is my sample data .

field1 ( name)  field2( age)  

a 1
b 2
c 4
d 5
e 3
f 2
g 5
h 5
i 2
j 1

The attached  wf  calls iterative macro  to pick 5 random records with average = 4 .  The maximum number of iterations is  100 .  

Hope this helps  . 

 

FrankieChai
5 - Atom

Thank you Benakesh for the solution.  This work beautifully.  Thank you!!

Labels