LogoLogo
ProductsPricingGlossary Launch Acho
  • 🎉Welcome
  • Introduction
  • What is Acho?
  • How does Acho work?
    • Proof of Concept (PoC)
  • App Builder
    • Get Started
    • Core Concepts
    • Overview
    • App construction
      • App Configuration
      • Pages
      • Interactions
        • Add an interaction
        • Add conditions to interactions
        • Event payload
        • Ordering interactions with action flow
        • Transformer
        • Actions
          • Navigation
          • Element
          • Data Source
          • App
          • Page
          • API Service
          • Database
          • Media Service
      • Table
      • Metric
      • Query
      • Data Store
      • Elements
        • Table & Chart
          • Searchable Table
          • Table
          • Chart
          • Score Card
        • Form Elements
          • Form
          • Search Bar
          • Checkbox
          • Date Picker
          • Custom Form
          • Input
          • Multiselect
          • Radio Button
          • Radio List
          • Rich Text Editor
          • Select
          • Switch
          • Textarea
          • Upload
        • Web Elements
          • Badge
          • Button
          • Clickable
          • Collapse Menu
          • Divider
          • Icon
          • Image
          • Link
          • Message
          • Modal
          • Notification
          • Pagination
          • Popover
          • Rate
          • Rich Text
          • Tabs
          • Text
        • Layout Elements
          • Container
          • List
        • Advanced elements
          • Code Block
          • Condition
          • Print
        • CSS Styles
          • General techniques
          • Layout
          • Spacing
          • Size
          • Position
          • Typography
          • Background
          • Border
          • Effect
        • Form Check
        • Tooltip
      • Accessors
      • Plugin Store
    • Popular Use Cases
      • Build a chart from Table Nodes
      • Create a table
      • Create a list
      • Create a filter
      • Create a search bar
      • Use Custom Form Container to collect user inputs
      • Drill down on a table
      • Download file from query node
      • Set loading animations
      • Modify a database
      • Navigate to a different page
      • Set up dynamic routing
      • Update app data using accessors
      • Create a Chart with Code Block and D3 Library
      • Rich text and rich text editor
      • Send an Email via Mailjet Plugin
    • Preview
    • Publish
      • Embed published app on website
    • Version Control
    • App User Management
      • Onboarding Page
      • Sign in page
      • Guest Isolation and Private Session
    • Theme
    • FAQ
  • Acho Studio
    • Quick Start
    • Resources
      • Add a resource
      • Supported data sources
        • Airtable
        • Amazon Ads
        • Amplitude
        • Amazon Seller Partner
        • Apify Dataset
        • Appstore
        • Asana
        • API Connector
        • API Template
        • AWS CloudTrail
        • Azure Table Storage
        • Batch Files
        • Bamboo HR
        • BigCommerce
        • BigQuery
        • Bing Ads
        • Braintree
        • Cart.com
        • Chargebee
        • Chargify
        • Chartmogul
        • Clickhouse
        • Close.com
        • CockroachDB
        • Confluence
        • Customer.io
        • Delighted
        • Dixa
        • Drift
        • Facebook Marketing
        • Freshdesk
        • Freshsales
        • Freshservice
        • GitHub
        • GitLab
        • Google Ads
        • Google Analytics
        • Google Sheets
        • Google Search Console
        • Greenhouse
        • Harness
        • Harvest
        • HubSpot
        • IBM Db2
        • Instagram
        • Intercom
        • Iterable
        • Jenkins
        • Jira
        • Kafka
        • Klaviyo
        • Kustomer
        • Lemlist
        • Lever Hiring
        • LinkedIn Ads
        • Linnworks
        • Mailchimp
        • Marketo
        • Microsoft Teams
        • Mixpanel
        • Monday
        • MongoDB
        • MySQL
        • My Hours
        • NetSuite
        • Notion
        • Okta
        • OneDrive
        • OneSignal
        • Oracle DB
        • Outreach
        • PagerDuty
        • Paypal Transaction
        • Paystack
        • Pipedrive
        • PersistIq
        • Pinterest
        • Plaid
        • PostgreSQL
        • PostHog
        • PrestaShop
        • Qualaroo
        • QuickBooks
        • Recharge
        • Recurly
        • Remote File
        • S3
        • Salesforce
        • Salesloft
        • SearchMetrics
        • Sendgrid
        • Sentry
        • Short.io
        • Shopify
        • Single File
        • Slack
        • Smartsheets
        • Snapchat Marketing
        • Snowflake
        • SQL Server
        • Square
        • Stripe
        • SurveyMonkey
        • Tempo
        • TikTok Marketing
        • Trello
        • Twilio
        • Typeform
        • VictorOps
        • WooCommerce
        • YouTube Analytics
        • Zendesk Chat
        • Zendesk Sunshine
        • Zendesk Talk
        • Zendesk Support
        • Zenloop
        • Zoho CRM
        • Zoom
        • Zuora
    • Data Prep (Projects)
      • Create a Data Prep Project
        • Create a table tab
        • Copy a table tab
        • Hide a table tab
      • Apply an action
        • View
          • Hide Columns
          • Filter
          • Sort
          • Cut
          • Rename
          • Move Column
        • Combine Tables
          • Join
          • Union
        • Transformation
          • Pivot Table
          • Unpivot
        • Data Cleaning
          • Cleanse
          • Replace
          • Change Type
          • Deduplicate
          • Split
          • Flatten
        • Tools
          • Formula
          • SQL Editor
            • SQL Editor Queries
            • All functions in Formula/SQL
              • Mathematical Functions
              • String Functions
              • Date Functions
              • Datetime Functions
              • Time Functions
              • Timestamp Functions
              • Conditional Functions
              • Type Conversion
              • Other Functions
        • Reserved Keywords
      • Pipeline
      • Edit your pipelines
      • Generate column summary for inspection
      • Use URL to access and share your project
      • Write a description for your project
      • Delete a resources/project/tab
    • Data Flow
      • Export data
        • Download CSV files
        • Excel Connector
        • Google Sheets Connector
        • Embed a table on your website
          • Data Usage Agreement
        • Apache Superset
        • Chartio
        • Looker
        • Metabase
        • Power BI
        • Qlik
        • Tableau
        • MongoDB
        • MySQL
        • MSSQL
        • Snowflake
        • PostgreSQL
        • BigQuery
    • Set up Data Sync
    • FAQ
  • Organization
    • Get started
    • Create an organization
    • Invite people to your organization
    • Share your resources
    • Share your projects
    • Share your apps
    • Change payment method on file
  • FAQ
    • I can't find data after uploading a big CSV file
Powered by GitBook
On this page
  • Setting up your query node
  • Example: Numerical and string inputs
  • Example: Array input
  • Create your elements for filtering
  • Create the interaction to change SQL parameters
  • What the form will do when it's submitted
  • Submitting the form

Was this helpful?

  1. App Builder
  2. Popular Use Cases

Create a filter

PreviousCreate a listNextCreate a search bar

Last updated 1 year ago

Was this helpful?

Combining and , you can allow users to filter data based on their input. This tutorial will show you how to use Form to collect user's input, use interaction to set SQL parameters in query nodes and filter a table.

Examples in this tutorial will reference table company_daily_stock_price containing stock information, you'll find the table in the sample Postgres database.

Setting up your query node

In order to use user inputs to change SQL parameters to filter your data, you'll need to add parameters to your node. The syntax to add parameters varies slightly based on the type of data node you are using. See Query for syntax details and more information on parameters.

Consider the data type output by the element triggering the filter. For example, a Switch element produces a boolean value, or a Multiselect produces an array. When initializing parameters, you'll want the initialized value to be of the same data type.

When building your query, you'll also want to make sure that the data type of the parameter matches the column that it's filtering. Your statement should handle any necessary type casting or additional processing.

The following examples are all queries made in PostgreSQL query nodes. To create such a query node, locate the company_daily_stock_price in table node list and create a query node from it.

Example: Numerical and string inputs

This example shows how to deal with numerical and string columns.

It will pull all records where total_volume is greater than or equal to the user's input for min_volume, and where exchange_short matches what the user selects. The query was built and parameters were initialized so all data is shown before the user selects any filters.

Query:

SELECT ticker, company_name, exchange_short, volume, close, change 
FROM company_daily_stock_price
WHERE volume >= {{min_volume}}
AND exchange_short LIKE CONCAT('%','{{exchange}}','%');
{
  "min_volume": 0,
  "exchange": ""
}

Example: Array input

Some form elements output arrays. For example, let's say we plan on having a Multiselect input element where I allow users to choose which ticker values they'd like to see data for, and display all rows where the ticker matches.

Query:

{% set comma = joiner() %}

SELECT ticker, company_name, exchange_short,  volume, close, change 
FROM company_daily_stock_price
WHERE 

{% if ticker_list | length > 0%} 
ticker IN ({% for ticker_item in ticker_list %}{{ comma() }} '{{ticker_item}}' {% endfor %}) 
{% else %} TRUE
{% endif %};

Parameter initialization:

{
  "ticker_list": [],
  "ticker_item": ""
}

This example shows how you can pull all records for the tickers that the user has selected. In this statement, if ticker_list is not empty, we use a for loop to reconstruct the array in the right format and check if ticker appears in it. If the array is empty, all records will be displayed.

Create your elements for filtering

A common way to create a filter is to insert Form Elements into a Custom Form. The form can then collect the inputs and use them to change your SQL parameters.

Following from the data node examples above, we've created a form, which contains an Input element to collect the minimum total volume, a Radio Button to select an exchange, and a Multiselect to select tickers.

Each form element has a form item name, which is the name that the form will use to access the user input. They're also configured based on the specifications in our query.

Create the interaction to change SQL parameters

Once the form elements and data node have been set up, the last step is to create the interactions that will change the SQL parameters.

What the form will do when it's submitted

Add interactions to change SQL parameters on the form element when it is submitted.

Add a Submit event block to the form, and create an action. Select API Service -> Set SQL Parameter. Make sure you're setting parameters under the right data node.

Access the user inputs from the event payload using ${event.form.min_volume} and ${event.form.exchange}.

Similarly, the interaction to filter tickers can be accessed with ${event.form.ticker_list}.

Submitting the form

We've set up the interactions to change SQL parameters upon submission of the form. However, we still need to create a way to submit the form.

On an element, such as a button, set up an interaction to submit the form.

Parameter initialization (See how to set parameter in ):

The parameter min_volume is initialized to 0, a numerical value that can be compared against the column total_volume. exchange is initialized as an empty string, and in the query, turned into a expression using the CONCAT() function. This allows all records to be pulled when the string is empty, and will match specific values when the parameter value is changed.

Minimum volume: The total_volume column is numerical, so we'll want to process the input as a number.

Exchange: Recall that in our query, we display all records when the exchange parameter is an empty string. So when a user selects the "All" option, the value we're changing the parameter to is empty.

Tickers: Add ticker values for the user to choose from. Either enter the value:label pairs into the input boxes, or click on </> under Options to use an accessor to an array of objects with "label" and "value" keys.

Regex
Query node
Interactions
#1.-add-new-parameter
company_daily_stock_price
Create the query node from company_daily_stock_price table node