You can filter a query within the page using variables as well as hardcoded values. Dynamic filters (using variables) can be applied based on the user, dynamic page, calculations or any of the many variables available.
Filter with Components
Let users apply filters in the frontend by adding input components to the page.
‘Quick’ Filter Components
In the components menu, some items allow you to skip the manual process of connecting components, variables, actions etc and simply follow a guided setup.
Apply on change
By default, filters will be applied automatically whenever the user changes the value. You can have the option toggled off to submit filters by adding a submit filters action.
Apply to Multiple Fields
After setting up the component, you can open it in the editor and apply more than one field to the same filter.
Custom Inputs + Variables
You can also create customized filters by adding input components, then referencing their values (as variables) into the query filter. If you use this method - remember to also add a Reload Query action to make sure the data is refreshed each time the value changes.
Create the input component.
Apply the Input variable to the filter.
The query will not automatically reload when the input value changes. Add a Reload Query action On Change to achieve this functionality.
Dont forget to make the query reload when the input value changes.
Create a Filter
You create your filters in the query using the customary logic (find xxx where yyy) and either static or dynamic values (variables). With this method, we are fetching records from the query table and filtering them to only return the records that match the conditions
Click to edit the query, then click to apply filters.
Choose a field to apply the filter to, the operator and the variable or value to filter by.
The resulting query will be :
Get records from [orders] where [customers] contains [customer.id]
The records will be returned in the same order as they are displayed in the view.
Records Array
You can also specify which records to fetch from the query table, by providing the ids of the records from a variable.
In this example we are on a dynamic page for a product which has a list of upgrades linked to it.
By passing the Product Upgrades as a variable, we tell the query to fetch only those records.
The resulting query will be :
Get [page.upgrades] from [Upgrades]
Because it is more direct, this method is faster and more efficient - but records will be returned in the same order as the linked field, and you can only use one variable in the filter.
View (ID)
To use Airtable’s powerful view, sorting and filtering you can pass the view ids into your query.
Steps
Add buttons to the layout for each view. Create a variable to store the view ID. Set the value of the variable when a button is clicked. Add the variable with the view ID to the dynamic view setting. Test the functionality in preview mode.