How to pass a filter from the Dashboard to a source SQL

Question:

Hi! I created a worksheet based on a SQL statement, using the SQL runner. How would I go about passing parameters from a dashboard input control to a SQL query that I'm using as the data source for a worksheet?

ANSWER:

  1. First, you put a SQL query parameter into the SQL query, using double curly brackets (see this article for details)

Here is an example of a source SQL statement with a Sigma parameter [Recruiter Parm] in it:

select * from EXAMPLES.COMMERCE.ALLSUMMARY
where
CASE
WHEN {{Recruiter Parm}} IS NULL OR TRIM({{Recruiter Parm}})=‘’ THEN True ---- if input parameter is blank, return all rows. Without this, blank parameter could lead to 0 row output
ELSE PRIMARYRECRUITER ILIKE ‘%’ || TRIM({{Recruiter Parm}}) || ‘%’ ---- case insensitive parameter by using ILIKE
END

  1. Next, you create a worksheet, that will recognize this parameter.

  2. Next, from the dashboard, using dashboard controls, you will set that parameter.

1 Like