We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Random samples from proportionate to ratio in 2 tables

rpilaniya3
5 - Atom

Hi all,

 

Need some experts help.

 

Just sharing my query with small example.

 

I have two data for different countries, data A with 5 different countries and data B with 3 countries.

 

The volume is both table will refresh for each country. I would want to select random samples of 30. But it should be proportional to ratio in tableA from data A and table B from data B 

 

That is if in table A country India is having 100 as count and table B india is having 200  , then my 30 random samples should be 10 data A and 20 from data B.

 

Kindly assist.

2 REPLIES 2
KGT
13 - Pulsar

So, you need to either union the table and stratify the sample or create your ratio and use that to sample the data.

 

Create the ratio:

  • Count Records on each dataset,
  • join on record position
  • Formula to work out ratio or whatever else you need.

 

Sample. There are many ways to do this. This is a quick brute force.

  • Add a column RAND()
  • Sort by that column
  • Sample Tool to take top X records OR
  • Record ID and filter to recordID<[Field]
Qiu
21 - Polaris
21 - Polaris

@rpilaniya3 
Can you share some dataset, so we can also work with a sample flow?

Labels
Top Solution Authors