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:
- 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
-
Next, you create a worksheet, that will recognize this parameter.
-
Next, from the dashboard, using dashboard controls, you will set that parameter.