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.
SOLVED

Need to segment the input file by randomly assigning a group ID

sraja
6 - Meteoroid

Hello All,

I have two input files and I want to create groups based on a Time Zone field. For example- File A has 150 records and File B has 20 records. I want to create 20 groups and allocate the 150 records to each of these groups, so will have approximately 7 in each group. Please advise on how I can accomplish this. I want to randomly assign 7 records from File A and associate the group # to a row in File B.

 

Thanks.

5 REPLIES 5
Qiu
21 - Polaris
21 - Polaris

@sraja 
Can you provide a set of sample input and output data?

caltang
17 - Castor
17 - Castor

You can use the RAND() expression and then MOD() it to 20, then whatever is left will be considered as group 20.

 

You can summarize once the values are present.

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
sraja
6 - Meteoroid

Can you please explain further on how to use mod and rand function, as the rand function will return values between 0 and 1

sraja
6 - Meteoroid

Please see below:

 

File B:

GroupName
111111
222222
333333
444444
555555
666666
777777
888888
999999
10111110

 

 

In File A, I want to randomly assign 7 "Name" to a group.

 

IDNameGroup Assigned
1AAA1
2BBB1
3CCC1
4DDD1
5EEE1
6FFF1
7GGG1
8HHH2
9III2
10JJJ2
11KKK2
12LLL2
13MMM2
14NNN2
15OOO3
16PPP3
17QQQ3
18RRR3
19SSS3
sraja
6 - Meteoroid

I was able to resolve the issue by using a formula using rand() and apply sorting on this new column and have another formula with ToString(Mod([ID] - 1, 20) + 1). 

Labels
Top Solution Authors