How to make a dynamic sorting APP?

by Longyan Chen

We did Macro and APP for today's training and I am going to make a dynamic sorting APP for one of the exercises we had earlier.

The task is to read in the file and sort the file by numeric and date field dynamically in the dropdown. Both Descending and Ascending should be allowed for sorting, with Descending as the default value.

First, drag a input file into the work canvas and then connect the data into Alteryx. Second, drag the sort tool from Preparation tool Palette into the workflow. As you explore the data, you will see the Application Deadline is the date field. So I choose Application Deadline in the Name and Descending in the Order. The worksheet shows like below:

Now I want to see if it works by adding a Browse tool after Sort tool and hit run. It works as I expected.

Now I want to make it dynamic and when the user read in any files that contains date field works like this and with both Descending and Ascending sort type.

First, I need to put the File Browse into the workflow from the Interface Palette and then name it as Select a input file that you want to sort. Please remember not to click Save AS a Dialog, because we only do when we save it as a output file.

When I dragged File Browse into the worksheet, the Action appeared automatically. I just left the Action as Update Input Data Tool(Default). Now I need to use the Drop Down tool to select the field to sort. Connect the anchors with File Browse and Sort too as below and write down the name for the Drop Down, then select the numeric and date type by ticking all fields that needed.

This time we need to choose the Update Value for the Action and choose the value to be Application Deadline. Because we chose the Application Deadline to be the date field that we wanted to sort in the Drop Down. After these have been filled in, please always remember to click on the white space to update what we have just done.

We have made input data and date field dynamic and now we need to drag in another Drop Down tool and allow it to have both Descending and Ascending. Unlike we did before, this time we do not need to connect the anchors with File Browse but Sort tool, because we just want to build the sort type nothing really need to be connected with the File Browse. Name the Drop Down Select your sort type. Then, select Manually set values and then type in Descending and Ascending in the Property box. We want Descending as default value, so I typed Descending on top of Ascending, also I typed in Descending on the Default Selection Name box, you can do either way and it will work.

Now we need to update the value in the Action by choosing the Update Value option and value='Descending' in Value or Attribute to Update.

After we build this APP, we want to test if it works. So click the Magic wand and input any file to see if it works with the numeric or date field. Please remember to turn on the Browse tool.

The APP works with test input data!!!

Fri 30 Sep 2022

Thu 29 Sep 2022

Wed 28 Sep 2022

Tue 27 Sep 2022