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

dynamic change of sample size based on number of records

starfailure
6 - Meteoroid

Greetings,

This probably isn't very complicated or difficult, but I'm a noob.

I need to count the number of records in an output, then use that number to determine (update) the value of N in the Random % Records tool, and apply to the same output.

Please could someone help me arrive at a solution?

 

7 REPLIES 7
morr-co
10 - Fireball

Hi @starfailure : the attached macro should do this for you. Simply map the N value to the upside down question mark input (control parameter)

 

Screen Shot 2020-10-28 at 3.09.10 PM.png

starfailure
6 - Meteoroid

Thanks @morr-co!  Appreciate the response.

A couple follow-ups.

- What upside-down question mark?

- How do I incorporate a macro like this into a standard workflow?

morr-co
10 - Fireball

No worries, below are the steps you need to take. A "macro" is essentially a workflow that you can use in another workflow. To accomplish this:

 

  1. Save the attached workflow above to your local machine
  2. In the workflow you are building:
    • Right click on the canvas
    • -> Insert
    • -> Macros (last option at the bottom)
    • -> Click Browse...
    • Select the file you just saved to your machine
  3. You will then see the macro on your canvas as it appears in the image below. To make it work:
    • Map the N input to upside down question mark input on top
    • Map the data you want to sample to the second input
    • When you click on the macro, select the Questions tab, and make sure your field containing N is mapped in the drop down.

Screen Shot 2020-10-28 at 3.22.50 PM.png

Qiu
20 - Arcturus
20 - Arcturus

@starfailure 

While @morr-co is taking the break, and utilize the macro to give a sample here. Hope it helps.

The question mark indicates that there is a question from Macro, requiring user configuration.

If helps, appreciate if you would mark it as accepted.1029-starfailure.PNG

starfailure
6 - Meteoroid

Thank you, both! 

I think you've provided the missing pieces.

Now to put it together..

Qiu
20 - Arcturus
20 - Arcturus

@starfailure Appreciate the mark. Have a nice day!

rbelski
6 - Meteoroid

Thank you for your macro instruction and example.  I've used it on a multi-stage sampling process that I've puzzled over all day!

 

 

Screenshot 2024-03-28 155800.jpg

Labels