Skip to main content
marcot0005
March 1, 2022
Solved

Filtering data

  • March 1, 2022
  • 5 replies
  • 1 view

If I've queried up some data, is there an easy way to filter that into smaller subsets without making new queries? For example if wanted a grid of 'all users', then I wanted second grid of all people with the first name 'John' and then a third grid of all the people with the last name 'Smith', is there a way to filter the data for the other 2 grids using the first grid's data? Or am I stuck making 3 different queries to the database? Would it be possible somehow to create local variables containing all three using a single query? 

Best answer by markc4162

Use the index function: index() Function - Appian 21.4.

Common pattern would be combining this in the format index(data, wherecontains(), null) in order to only find the data in your set that meets there wherecontains() condition.  You can create the subsequent indexes as local variables following the first local variable with the parent/top-level grid data.

5 replies

stefanhelzle0001
Brainy
March 1, 2022

That would be possible. Have a look at a!localVariables and the filter() function.

But in general, it is a bad idea to load larger volumes of data into Appian and then try to filter it in memory. The database is made for this and will not complain.

andrewh0007
March 1, 2022

Agreed with Stefan. You should generally avoid getting the same data twice but different data from the same source is a separate matter. It depends on the exact use case but multiple calls to the database may be more performant than getting all data and transforming it in Appian. 

markc4162Answer
March 1, 2022

Use the index function: index() Function - Appian 21.4.

Common pattern would be combining this in the format index(data, wherecontains(), null) in order to only find the data in your set that meets there wherecontains() condition.  You can create the subsequent indexes as local variables following the first local variable with the parent/top-level grid data.

marcot0005
March 2, 2022

This works, thanks!