How to use dynamic query inputs?

Dynamically change SQL variables using UI input fields

When do you use Dynamic Query Inputs?

You use Dynamic Query Inputs when you need to run the same query multiple times but need to change some of the variables in the query before you run it each time. For example, if you have a query that generates a monthly sales report and you need to change the Country before you run the query. Instead of directly editing your SQL to update the Country variable from "US" to "Canada", you can use dynamic query inputs to change the variable using input fields.

Dynamic query input variables on Castodia

Why use Dynamic Query Inputs?

  1. It helps you change the same variable across your entire SQL query. This is helpful if your query is written in a way that you need to change the same variable in multiple parts of your query. With dynamic query variables, you only need to change it once through the UI and it will update across your entire query.
  2. Editing SQL queries directly results in more errors that are harder to catch and result in your queries not running as expected.

What kind of variables can I dynamically change using this feature?

There are 2 types of dynamic input fields. Variables and date offsets.

  1. Variables: You can dynamically change variables using the ${YOURVARIABLE} syntax. Simply replace the variable you want to modify using the UI input field with the name of your variable enclosed by the dollar sign $, followed by curly brackets around your variable name {}
  2. Date offsets: You can dynamically change date offsets using the @{DATEOFFSET} syntax. Simply replace the dates you want to offset using the UI input field with the name of your variable enclosed by the @ sign, followed by curly brackets around your date offset variable name {}. To learn more about how to use offsets, click on this help article.

Book demoStart free trial

Try Castodia free for 14 days, no credit card required.