community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx Knowledge Base

Definitive answers from Designer experts.
Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE

Configure a Workflow to use a Tree Interface Tool

Alteryx
Alteryx
Created on

So we’ve generated our list of Key Values (in Part 1) to be read by the Tree Interface tool and when we look at the Tree Interface it looks correct.

 

example tree.png

Figure 1

 

So how can we use these selected values in a workflow?

As a review, our original data consists of very pretend pet data.

 

sample data.png

Figure 2

 

Now we need to associate the Key Values to our data so that our data can be queried.  This can easily be done by adding a couple steps to the workflow we create in Part 1  (updated workflow is attached).

 

By adding a Transpose tool, the table can be manipulated to get each possible Key Value for each record. Then a Select Tool to rename the Value field to Key. Those results are saved to a new file (Pet data with key values.yxdb) that will be used in the app.

 

Data with key values.png

Figure 3

 

When values are selected in a Tree, a list of the Key Values are returned with a line break between each value.  In the above Tree Interface example (Figure 1) the Key Values 111 and 26 are returned as a string data type and would look like this: 

 

example results from tree.png

Figure 4

 

Setting up the App

We now have all the parts we need to create the app: Pet Key values.yxdb (from Part 1) and Pet Data with Key Values.yxdb

 

The start of the app is a Tree Interface tool that points to the Pet Key Values.yxdb file, and an Input tool pointing to the Pet Data with Key Values.yxdb file.

 

Initial set up.png

Figure 5

 

We know the Tree Interface returns a list of Key Values, so we can then filter our pet data on the Key Values.  A Filter tool is added with a template filter that will ultimately be updated by an Action tool, once we connect the Tree Interface to the Filter tool.

 

filter example.png

Figure 6

 

Now let’s connect the Tree tool to the Filter tool and configure the Action tool.

 

filter with action tool.png

Figure 7

 

We are going to select the Action Type ‘Update Value with Formula,’ and update the full Expression. Now for the Formula: click on the ellipsis (…) to add this formula:

 

'[Key] in ("' + REGEX_Replace([#1], '\n', '","') + '")'

 

action tool config.png

Figure 8

 

This expression will build an IN statement (Figure 5) based on the selected values from the Tree Interface.  If the returned values from the Tree tool are, as in Figure 4:

 

111

26

 

The expression will build a string starting with:  [Key] in (“

 

The REGEX expression looks for all line breaks (or newlines) in the connection 1 ([#1]) value, denoted by the \n, and replaces those occurrences with: “,”

 

And then finishes the expression with: “)

 

The final expression looks like this: [Key] in (“111”,”26”)

 

This will replace our template expression when the app is run.

 

To test your Action tool expression, use the Interface Designer’s Debug tool.  Open the Interface Designer from the View menu in Alteryx.  This Community article goes into more detail on how to use the Debug tool.

 

With that, the tree tool is complete.  The Key Values from the selected Tree Interface items are used to select the desired records from the dataset for further processing.

 

Add a Browse tool to the True output of your Filter to view the results when the app is run. Be sure to configure your app to show the results of the Browse when the app completes. This setting can be found in the Interface Designer, under Properties.

 

interface designer.png

Figure 9

 

As with many things in Alteryx, there is usually more than one way to accomplish a task.  In the attached App example workflow, there is an additional method to take the results from the Tree tool and query the pet dataset.

 

All related workflows are attached to the post and saved in Alteryx 10.0 format.

Attachments
Comments
Alteryx Certified Partner

I am working on an app using Tree where first level is a table then it should reveal the columns in that table.  The only difference I am dealing with on this is that I only need 1 key (table 1 = 1, table 2=2, etc, etc)  I can get the data out after selection in the app but I can't get to a point where I am able to select specific columns.  Any thoughts?

Meteor

This is a great method for very small datasets. But for large datasets, this method is prohibitive in that it's basically duplicating the dataset it's intended to filter. What if you're trying to filter an InDB dataset with millions of rows?

Alteryx Partner

This post really helped me out.  Thanks immensely for the thoroughness and details, and the example flows, much appreciated!

Meteoroid

@PeterS & @RodLight can you please share your solution for more than 9 values? I haven't been successful yet implementing the padleft() function. Thanks!

Alteryx
Alteryx

HI @PeterS , 

 

I am running into an issue where trying to leverage the tree interface tool to update a report header in the 'Report Text' tool. The issue I am coming across is that it updates the header to the key value, not the data itself. Wondering if you might know a workaround?

 

@LisaL 

 

Thanks,

Mike

Alteryx
Alteryx

Hi @MichaelSu,

 

That sounds like expected behavior. If you are directly taking the values from a Tree selection you will get a list of key values returned as noted in Figure 4 above.  Once those key values are selected they need to be parsed and then can be Joined or Filtered with the table that contains the desired data and Key values as noted in Figure 7 above.  Once that is done you can get the desired values to be used in the Header report tool.

 

Hope this helps!