Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Generate list of 10 random comments per client

max_hfr
8 - Asteroid

Hi guys,

 

I'm struggling to find a way to automate a random extract on a csv input.

 

Let me explain myself:

 

I have 2 columns :

- [Client ID]  // is not à unique key

- [Client Comment]

 

 I want to randomly select  exactly 10[Client Comment] per [Client ID]

 

While it would be easy to radomly select X [Client Comment] , I can't find a way to add the variable "with exactly 10 [Client Comment] per [Client ID]".

 

Thank You in advance

4 REPLIES 4
Karam
8 - Asteroid

Hi @max_hfr,

 

One option is to create a batch macro that read a list of client IDs, and then within the macro itself it selects random 10 comments (for each client ID that passes through the macro).

 

Karam

jdunkerley79
ACE Emeritus
ACE Emeritus

A simple trick is to add a random number via a formula tool, then sort by ClientID then this.

 

2018-10-24_10-12-58.png

 

Then you can use a sample tool grouped by client ID to pick 10 random messages.

Ladarthure
14 - Magnetar
14 - Magnetar

Hi,

 

another way to do that is to use the rand() function and then sort by it, get the n first values. I made a sample workflow, tell me if it works for you!

max_hfr
8 - Asteroid

Thanks a lot!

Labels