Parameters

Introduction

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

Add data from Sheets

To add data from Sheets, follow these steps:

  1. Add a parameter to your SQL.

    select e.*
    from dummy.events AS e
    where 1=1
    and e.email like '%{{email}}%'
    limit 200
  2. As soon as you add a parameter to your SQL, a "Parameters" section appears in SeekWell. Select Sheets as the Type.

    Add Parameters to SQL

  3. Select the Spreadsheet you want to grab the parameter value from and the cell using A1 notation (for example, Sheet1!A1). You can only use a single cell, except in the case of Postgres and Snowflake. If you need to reference multiple cells, use and / or statements.

  4. Run the query and results appear based on your parameters.

Add data from another Block

Select "Block" as the parameter type.

Select Block as parameter type

Lists and tables (Postgres and Snowflake only)

You can also use a Sheet range, or more than one cell, to generate a SQL list (for example, 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, refer to 🔍 Query Sheets using SQL.

Setting parameters in the URL

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

https://app.seekwell.io/run/<youruuid>?param1=value1&param2=value2

Or for a 📋 Forms:

https://app.seekwell.io/form/<youruuid>?param1=value1&param2=value2

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

Share block

Trigger actions on load

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

You can also set a special parameter of viewNumber to control the view when a block loads. For example, ?viewNumber=3 will show a full-screen table. Here are the other options:

  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.

    Choose Select as parameter type

  3. Choose the block you created in the first step and the column from that block you want to use in the dropdown.

You can even create a dropdown impromptu 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 select statement, for example:

    SELECT {{email}}, r.revenue
    FROM dummy.revenue AS r
    WHERE 1=1
    limit 2
  2. Select the Drill Down type.

    Select type as Drill Down

  3. 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, your SQL would be email. The parameter names must be the same between the two blocks.

    Select parameter names for your block

  4. The parameter will now show as a link in the results and selecting on the link will drill to the block you set in the parameter.

    Email appears as link in results

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.

Editable parameter type

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 (for example, {{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

Add a parameter to your select statement

Hovering over an editable cell changes the background to black, and you can now change the value. Select the Save icon to run your update block.

Hover over an editable cell Select Save

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 select 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 want to add from the drop-down:

Select Subquery parameter type

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 Intercom for details on this type.


Was this page helpful?