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

Random sampling but taking into consideration multiple fields

JP_1
6 - Meteoroid

Hi there,

 

I am looking to sample based on a unique field but don't want to sample a person more than once.  I hope that makes sense but I have put a basic example of the data I am working with below.  E.g. I want to randomly select/sample 3 rows but do not want to sample a name more than once.  So if in the random sample AB345 Alex was selected/sampled, then no more Alex's should be part of the sample.  There should be three unique names in the sample.


I have tried a few things but unfortunately cannot get to the answer - would appreciate the help please.

 

UNIQUE FIELD NAME
AB345Alex
GF458Brad
DC367Charlie
VG689Dave
FG234Ethan
AV001Charlie
YT534Brad
FE123Dave
LF823Dave
PF287Alex
RT987Charlie
LL433Dave
10 REPLIES 10
Emil_Kos
17 - Castor
17 - Castor

Hi @JP_1,

 

I like simple solutions. Please let me know if this is something that you have been looking for.

 

Emil_Kos_0-1604570828467.png

I have used a combination of two sample tools because I believe this is the easiest way to get the desired result.

If this was something helpful please mark my solution as an answer!

Good luck! 

JP_1
6 - Meteoroid

Hi, thank you for the reply.  Unfortunately this wouldn't work as I am working with circa 5000 records.  Some names appear 100 times, some names appear once.  Effectively sorting alphabetically or even removing duplicates doesn't alone work as the unique identifier is important as it matches up to other important fields.

Emil_Kos
17 - Castor
17 - Castor

Hi @JP_1,

 

The first sample tool in my workflow keeps only 1 unique name. What would be the next step that you want to achieve?

 

Emil_Kos_0-1604571519219.png

 

You want to randomly sort them and keep x amount of lines? 

Emil_Kos
17 - Castor
17 - Castor

Hi @JP_1,

 

Alternatively, you can use a random % sample generator and you can pick any amount of lines that you want and there will be only 1 per name as the first sample tool removed duplicates.

 

Emil_Kos_0-1604571947049.png

 

JP_1
6 - Meteoroid

Ok understood.  Does the first sample tool just select the first unique identifier it finds per name? 

Emil_Kos
17 - Castor
17 - Castor

Hi @JP_1,

 

Yes, it works like this. 

If you want to randomize them first I have attached a sample workflow for you.

 

Emil_Kos_0-1604572453416.png

 

Emil_Kos
17 - Castor
17 - Castor

Hi @JP_1,

 

If the solution that I provided you was helpful please mark my answer as a solution!

 

If you need anything else please let me know.


Good Luck!

JP_1
6 - Meteoroid

Thank you!

Emil_Kos
17 - Castor
17 - Castor

Hi @JP_1,

 

No problem. Happy to help!

Labels