Alteryx Designer Desktop Discussions

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

Assign category for all the records with the percentage of allocation for each value.

_VigneshRaja_
7 - Meteor

Please assist to randomly assign the categories to the input data

 

Input

RecordIDField 1Field 2
1User 1100
2User 2200
3User 3300
4User 4400
5User 5500
6User 6600
7User 7700
8User 8800
9User 9900
10User 101000

 

Category List

CategoryPercentage of allocation
CAT00120%
CAT00230%
CAT00310%
CAT00440%

 

Output

RecordIDField 1Field 2Category
1User 1100CAT001
2User 2200CAT004
3User 3300CAT002
4User 4400CAT003
5User 5500CAT001
6User 6600CAT002
7User 7700CAT002
8User 8800CAT004
9User 9900CAT004
10User 101000CAT004

 

3 REPLIES 3
Qiu
20 - Arcturus
20 - Arcturus

@_VigneshRaja_ 
This is a very challenging one...

Hope someone can crack it. 😁

SPetrie
12 - Quasar

I took a shot at it and here is what I came up with. It gets a bit fuzzy with odd numbers of records or percentages, but it may get you close to what you are looking for.

I have it figure out how many records are in the main data and then use the percentages in the allocation chart to figure out how many rows are needed for each category. I generate the number of rows needed based off those numbers so I have the correct (or close to correct) number of rows to assign to the main data.

I also assign a random number to each row of the main data and then sort it by the random number so it scrambles up the data. I use a join on position to add the categories to it and then sort back to original order. 

We get random assignments each time its run. 

SPetrie_0-1660274238147.png.

SPetrie_1-1660274280397.png

 

 

flying008
14 - Magnetar

Hi, @_VigneshRaja_ 

 

Maybe you like this way:

 

录制_2022_08_12_13_27_34_109.gif

Labels