Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

"Weighted" Sampling

arods
6 - Meteoroid

Hello, so i'm stuck trying to find a solution for my problem and i would apreciate any help.
Let's suppose I have a column for State where the same State can repeat several times.

 

arods_0-1682454726113.png

 

I wanna take a random sample of my data but the thing is whathever this sample is it has to be the same proportion of my original data.
In my original data New York is 50% of the records, Maine is 17% and Massachusetts is 33%, in my sample they have to be in the same proportion.
Let's say i want a sample with 6 registers, the output could be this:

 

arods_1-1682454832962.png

 

Or this: 

 

arods_2-1682454855755.png

 

(Keep in mind my original data set has 5000 "States" not only three so i would like a generic solution.)

 

I will be very grateful to anyone who can help me.

 

 

4 REPLIES 4
Matthew
11 - Bolide

 could use the sample tool, group by the state column, and choose a random sample from each state

Matthew_0-1682455725081.png

 

arods
6 - Meteoroid

Hi, thank you for the answer, but in my original database i have 5000 states so no way i could do it for every single state it would take too much time

PhilipMannering
16 - Nebula
16 - Nebula

Similar approach to @Matthew: Creat a field RAND() → Sort by new field → Take % of data with a grouped by State in Sample Tool,

PhilipMannering_0-1682455925886.png

 

Matthew
11 - Bolide

@arods  .... the tool automatically does the grouping.

Labels