Skip to main content
Intelligent Apps support dynamic query generation using variables and Jinja-style templating. This allows you to build flexible dashboards that respond to user input from filters and variables.

Basic Variable Substitution

You can reference variables in your SQL queries using double curly braces:

Conditional Query Blocks

You can use Jinja-style control structures to include or exclude parts of your query based on variable values:

Using Multiple Variables

Combine several variables for more complex filtering:

Example: Dynamic LIMIT

You can use variables to control query limits:

Example: IN Clauses with Lists

If your variable is a list, you can use Jinja to join values for an IN clause:

Best Practices

  • Always provide sensible defaults for variables to avoid empty queries.
  • Use {% if ... %} blocks to prevent SQL errors when variables are empty or unset.
  • Sanitize and validate user input where possible.

Reference: Jinja Syntax

  • {{ variable }}: Insert variable value
  • {% if ... %} ... {% endif %}: Conditional blocks
  • {% for ... %} ... {% endfor %}: Loops (for advanced use)
  • Filters like | join(", ") for lists
See also: Filters, Overview, Charts