Alteryx Designer Desktop Discussions

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

Creating a interface to select X rando sample of items

Cesc
8 - Asteroid

Hi, I am trying to create an analytic application to select random items.

 

The critical fact is that the user must select how many items he wants to get. The maximum minumum size of the sample is 1 and the maximum size of the sample must be 25.

 

The user will have to select 2 choices in the inteface:

 

Cesc_0-1660046865499.png

 

If he inserts a .xlsx sheet and it has less items than the sample size he selects, it should make the user start at the first stage (and I don't know how to do that).

 

Also, once the user selects the sample size, the tool random should set the number of the sample size indicated by the user and set it in the random sample tool: (the number in yellow should always be between 1 and 25, and it should be getting the data from the user interface)

Cesc_1-1660046964743.png

Could you please help me build the interface and solve the actual problems?

I am attaching what I have been able to do untill now, and a population that shoud be choosing the sample for.

 

Thank you,

Francesc

9 REPLIES 9
Cesc
8 - Asteroid

Could someone help me out? I still have the problem. Thank you.

Christina_H
14 - Magnetar

I've got this working with two small changes.  First, you're not actually importing the data you want to sample, only a file path.  Run this through a dynamic input tool to bring in the data.

Christina_H_0-1663690528233.png

 

Second, I don't think your sample tool was updating correctly, I changed the settings so that the 1000 value is being replaced by the user entered value.

Christina_H_1-1663690592424.png

 

With those changes, I get results from the app:

Christina_H_2-1663690639988.png

 

AndrewSu
Alteryx
Alteryx

@Cesc , could you clarify what you mean when you say "If he inserts a .xlsx sheet and it has less items than the sample size he selects, it should make the user start at the first stage (and I don't know how to do that)"?  What is the "first stage"?

Cesc
8 - Asteroid

Hi @AndrewSu Andrew, trying ot explain myself better:

in case the item from the selected .xlsx list has for example 10 items and the user selects to extract a sample of 15 i mean that the alteryx should show and error and make the user execute the script again. 

AndrewSu
Alteryx
Alteryx

@Cesc , thanks for the clarifications.  Do all the possible files that can be selected have the same format/schema? Or is it possible that there is a difference in format?  and is it always going to be a csv/xlsx file type?

AndrewSu
Alteryx
Alteryx

@Cesc , please check out the attached workflow package which contains a chained app. 

 

(helpful interactive lesson on chained apps here: https://community.alteryx.com/t5/Interactive-Lessons/Chaining-Analytic-Apps/ta-p/243120 )

 

I basically split up the workflow so that the selection for the number of random selections is dynamic based on the input file provided.

 

Assuming that the input files are all the same schema and format, this should work and you don't have to worry about any error handling because it will be impossible for someone to set a sample size that is greater than the number of rows/records in the selected input file. 

 

Note that I had an issue with the bottom stream output tools overwriting the top stream output tools given the conditions of the filter tool.  IE. if I uploaded a file with more than 25 records, the Sample Selection.csv file would always be empty because it was still resolving the FALSE output of the filter tool.  The article below helped me solve this issue to ensure that data is only written if values are present and the sheet is NOT EMPTY. 

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/How-to-not-create-output-when-no-recor...

 

APP 1

 

AndrewSu_0-1663698898346.png

 

 

APP 2

AndrewSu_1-1663698945949.png

 

I hope this helps!  If this resolves your issue, please mark it as a solution so that the rest of the community can know and benefit from our collaboration. 

 

Thank you. 

 

 

 

 

 

 

Cesc
8 - Asteroid

Hi @AndrewSu ,

 

I really appreciate your answer. We are already using the workflow and understanding how it works. It defenetly solved our doubt.

 

Answering to yesterday's question, we do have only inputs in csv and xlsx.

 

Kind regards,

Cesc

AndrewSu
Alteryx
Alteryx

@Cesc , happy to help!  Please mark my post as the solution so that other's in the community can benefit from our collaboration. 

 

Thank you!

Cesc
8 - Asteroid

@AndrewSu , Done!! Thank you again!

Labels