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

Sampling N Records in Category based on condition

tjamal1
8 - Asteroid

Hello,

 

I am using Sample Tool to get the N number of Products for Each Category .

Is there anyway to Get N number of records in each category based on Some condition.

 

Example

If Category is 'A' or Category is 'B' then Get 10 Products for this category 

Else Get 5 Products for remaining Categories.

 

Data: (2 Columns)

CategoryName

ProductName

 

 

3 REPLIES 3
afv2688
16 - Nebula
16 - Nebula

Hello @tjamal1 ,

 

I have created a little workflow that should fill your request 🙂

 

Untitled.png

 

If you need anything else let me know 🙂

 

tjamal1
8 - Asteroid

@afv2688 Thank you for your workflow. It helped. 

 

I have one question, If my Column Names will change in the table and I add more columns to my table, Will it affect the  Macro you designed and will it needs to be changed? 

afv2688
16 - Nebula
16 - Nebula

Hello @tjamal1 ,

 

the workflow uses the "Category" column to do the counting and the sampling, you could either have the column renamed before entering into the treatment performed or edit the macro to match your column name, as you wish 🙂

 

Regarding your second point, you can add as many columns as you like, it shold not be affected.

 

Regards

Labels