Parameters

Introduction

With parameters you can inject data into your SQL statement. You can input plain text / numbers or inject data from Sheets or another block.

Add data from Sheets

  1. Add a parameter to your SQL
  2. select e.*
    from dummy.events AS e
    where 1=1
    and e.email like '%{{email}}%'
    limit 200
  3. As soon as you add a parameter to your SQL, you'll see a "Params" section show up in SeekWell, select Sheets as the Type
image

  1. Select the Spreadsheet you want to grab the parameter value from and the cell using A1 notation (e.g. Sheet1!A1). You can only use a single cell (except Postgres and Snowflake, see below). If you need to reference multiple cells, use and / or statements.
  2. Run the query and you'll get results based on your parameters!

Add data from another Block

Select "Block" as the parameter type

image

Lists and Tables (Postgres and Snowflake only)

You can also use a Sheet range (i.e. more than one cell) to generate a SQL list (e.g. where some_column in (1, 2, 3)). To use the list in your query, simply add the parameter (no parens, quotes, etc. needed), for example:

select *
from some_table as d
where d.some_column in {{vals}}

If you need more power in querying a Sheet, checkout

Setting params in the URL

You can set parameters in the URL to share links that automatically update the parameters

https://app.seekwell.io/run/yourreallylonguuid?param1=value1&param2=value2

Or for a

https://app.seekwell.io/form/yourreallylonguuid?param1=value1&param2=value2

Click the "Share block" link in the top right to get the link with the current parameter values

image

Trigger actions on load

To run a block as soon as the app finishes loading, set runOnLoad=1 . o

You can also set a special parameter of viewNumber to control the view when a block loads, e.g. ?viewNumber=3 will show a full screen table. Here are the rest:

  1. Split
  2. Full screen code
  3. Full screen table
  4. Charts

For example, the link below will set the param "email" to jim@seekwell.io, run the block and display the results full screen:

https://app.seekwell.io/run/yourblockid?&runOnLoad=1&viewNumber=3&email=jim@seekwell.io

Creating a dropdown / select parameter

  1. Create a block with the options you want in the dropdown (see video below)
  2. Choose "Select" as the parameter type
  3. image
  4. Choose the block you created in step #1 and the column from that block you want to use in the dropdown

You can even create a drop down on the fly with SQLite and the "Sheets / CSV / Block" source type

SELECT *
  FROM (VALUES ("dog"),
               ("cat"),
               ("bird")
       ) as a

Drill Downs

  1. Add a parameter to your your select statement, e.g.
  2. SELECT {{email}}, r.revenue
    FROM dummy.revenue AS r
    WHERE 1=1
    limit 2
  3. Select the Drill Down type
  4. image
  5. Insert the SQL that will display and select the block you want to drill to. For example, if you were selecting email from a table and wanted to drill to another block that had email as a parameter, you SQL would be email. The parameter names must be the same between the two blocks.
  6. image
  7. The parameter will now show as a link in the results and clicking on the link will drill to the block you've set in the parameter!
  8. image

Editable

You can use the "editable" parameter type to make columns values editable. You can then pass the entire row into another block to perform SQL updates. For example, say you had a users table that had the columns plan and email.

image

Create a block to update the plan with the following SQL:

update dummy.users 
set plan = '{{plan}}' 
where email = '{{email}}'

Add a parameter in your select (e.g. {{plan}}), choose the "Editable" parameter type and select the block you created above as the "Update with" block. The "SQL" field is the SQL to get the current value.

select d.email, {{plan}}
from dummy.users AS d
order by created_on desc
limit 100
image

Hovering over an editable cell changes the background to black and you can now change the value. A "Save" icon will also appear, click it to run your update block.

image

image

The entire row is passed into the update block, so the email in the row you updated is used as a parameter in the update block. In our case, the update SQL becomes:

update dummy.users 
set plan = 'premium' 
where email = 'alan4rk1m0x10crkb7d@somecompany.com'

Subqueries

You can add the SQL of any block into another block for use in a subselect or CTE. Once a subquery is added, you can click on it to drill down to the child query.

Parent Block

SELECT u.email, u.channel, r.revenue
FROM dummy.users AS u inner join
({{revenue}}) as r on u.email = r.email
WHERE 1=1

Select the "Subquery" parameter type and select the block whose SQL you a want to add from the drop down

image

Child Block (revenue)

SELECT 
r.email, 
sum(revenue) as revenue
FROM dummy.revenue AS r
WHERE 1=1
group by 1
order by 2 desc
limit 200

Intercom

See

for details on this type