How it works
Understand how variables works in Typper BI
To enhance the interactivity and dynamism of your SQL queries in Typper BI, you can incorporate SQL variables using the Handlebars.js templating language. These variables allow end-users to input or select values that modify the SQL query in real-time.
Example Usage
Suppose you want to create a query that retrieves information from an orders table, but you’re interested in a specific order ID. Instead of creating multiple queries for each ID, you can use a variable like so:
In the query above, {{order_id}}
is a variable placeholder. When the query is run, the user is prompted to enter a value for order_id, which is then directly inserted into the query before execution.
Variable Types
Typper BI currently supports the following types of variables:
- Date: For inputs that require a date value. Users can input dates through a date picker interface.
- Number: For numeric inputs. This can be useful for setting thresholds, limits, or specific numerical identifiers.
- Text: For string inputs. This is ideal for text-based queries, such as searching for a customer name or a product category.
- Boolean: For true/false inputs. This allows users to toggle conditions on and off, such as including or excluding certain data sets.
Each variable type ensures that the input from the user is in the correct format for the query to run successfully, preventing errors and ensuring data integrity.
Implementing Variables
To implement a variable in your SQL query:
- Determine the part of your query that will change based on user input.
- Replace that segment with a Handlebars.js variable syntax, e.g.,
{{variable_name}}
. - Specify the type of variable in the query or interface to ensure proper functionality.
Users will be presented with the appropriate input field based on the variable type, which will then replace the placeholder in the SQL query when executed.
By utilizing SQL variables, you create a user-friendly reporting tool that can be customized and adapted for various reporting needs without the need for multiple versions of the same query.
Was this page helpful?