WeeklyAlteryxTips#16 The way to combination of the List Box tool and Filter tool

Alteryx

This blog post is the tips about the Interface category tools.

The List Box tool can allow you to select the multiple items. But I think that the Designer’s sample workflow don’t have enough samples, so it is difficult to know how to use the combination with the Filter tool.

At this post, let’s see the way how to use the List Box and to filter the multiple items with the Filter tool.

Show the item list at the List Box tool

There are some ways which you set the list items on List Box tool. At this time, I would like to introduce the way how to show the data from the input data.

When you want to use the data outside the List Box tool, you should to input the list items as field names into @ input on the List Box tool as below. Honestly, I think this is not intuitive.

For example, I would like to use the data as follows.

For this data, connect as follows.

The setting of the Cross Tab tool is as follows.

The important point is specifying the field which you want to show at the List Box to the “Change Column Headers” option. After that, you can have the result as follows.

Allow the Filter tool to filter multiple selections

Well then, allow the Filter tool to filter the multiple items which you select at the List Box tool.

First, make the workflow as follows.

The setting of the List Box tool

When you want to use the combination of the List Box tool and the Filter tool, you need to use “Generate Custom List” option. The default option “Select Tool Mode” is not appropriate. Fortunately, when you use the option “Generate Custom List”, you can use the default setting of the start text, separator and end text.

I would explain the more detail. If you don’t want to know the detail, you can skip the follows.

If you select the “Select Tool Mode” option, when you check the Grape, Orange and Watermelon, the Action tool catch the data as follows.

According to this, the data is that items with no check are “False” and checked items are “True” with comma separated. The type of data can be used with the Select tool and etc tools, but the Filter tool can not be acceptable.

However, when you set the “Generate Custom List” option with default setting, you can get only checked items with comma separated. In other words, you can get the items which you selected on the List Box as follows.

We can use this type of data for IN operator. So, you can use it to judge the items which is match or not on the Fiter tool as follows.

[Item] IN ("Grape","Orange","Watermelon")

Let’s do it at the Action tool. But before to do it, I would like to set the Filter tool.

The setting of the Filter tool

You need to set the Custom filter at the Filter tool to overwrite whole setting by the Action tool. Just in case, set the correct setting to filter some items for debugging.

The setting of the Action tool

Select the “Select an action type” as “Update Value with Formula” as the same of the last week’s tips. And “Value or Attribute to Update” is “Expression – value”.

The Formula is as follows.

'[Item] IN ('+[#1]+')'

This is the important point. “[#1]” means the data which is coming from the List Box tool connected with the Action tool. In other words, the items which you select on the List Box with comma sepalated will be coming.

Note that you just make the string to overwrite the Filter tool’s setting at the Action tool. In the other words, you just make the string for the setting, not formula. So you need to enclose the formula in quotation marks.

For example, if you set the formula below at the Action tool, the Designer show error.

[Item] IN ([#1])

The result of running

If you make the workflow correctly, you can confirm the correct result as follows.

Summary

I explained filtering multiple items using the List Box tool and the Filter tool. There are only a few samples, so I hope you use it effectively.

Sample Workflow Download

Contents of the next blog

The next blog post is about asset management.

コメント

タイトルとURLをコピーしました