Parameters
Parameters are an easy and powerful way to add filters to your query/dashboard. Allowing you and others to interact with the query in the user interface without changing the SQL.

What are Parameters?

Parameters are a specialized feature of dune that allow you to implement variables in certain parts of your query code. This variable can be changed from dashboards and therefore allows you to make a interactive dashboard.
Parameters allow you to make changes to certain defined parameters of your code with a few simple clicks. For instance instead of hard coding contract_address , symbol or date ranges you can just use the parameter function to change these aspects of your code using a parameter. This allows you to build an interactive dashboard that the viewer can use to query for exactly the data he needs.
Parameters are defined in the query code as {{parametername}} and will appear below the query and in any dashboards in which a query visualization with parameters is used in.
You can pass on input to the parameter below the query or at the top of your dashboard. Simply run the query or click apply in your dashboard to rerun the queries/dashboard with the newly put in parameters.
Parameters in a Dashboard can be shared between different queries, just make sure to use the same name between all of them.

How to use Parameters?

You can simply add a parameter to your queries by writing {{parametername}} or using the button below the query. You can order them by prefacing them with the corresponding position you want the Parameter to appear in the User Interface : {{1. parametername}}.
You can edit the properties of single parameters by clicking on the litte gear wheel next to the parameter in the query editor. This allows you to set a default value, define a list of possible parameters or change the type of the parameter.

Example Query

This query returns the running total of Gas Paid in USD.
The Query Author has chosen to include a parameter for wallet address, start date and end date.
1
with alltransactions
2
AS (
3
SELECT
4
block_time,
5
success,
6
gas_price/10^9 AS gas_prices,
7
gas_used,
8
(gas_price*gas_used)/10^18 AS eth_paid_for_tx,
9
hash
10
FROM ethereum.transactions
11
WHERE "from" = CONCAT('\x', substring('{{1. Eth Address}}' from 3))::bytea
12
AND block_time >= '{{2. Start Date}}'
13
AND block_time < '{{3. End Date}}')
14
15
SELECT
16
date_trunc('minute', block_time),
17
SUM(eth_paid_for_tx*price) over (ORDER BY date_trunc('minute', block_time)) AS "Total Gas Fees Paid in USD"
18
FROM alltransactions
19
LEFT JOIN
20
(SELECT
21
minute,
22
price
23
FROM prices.usd
24
WHERE
25
symbol = 'WETH' AND
26
minute > '{{2. Start Date}}') AS prices
27
ON date_trunc('minute', block_time) = minute
28
ORDER BY block_time DESC
Copied!
Find this query here

Example Dashboards

Find interesting stats on Ethereum Wallets with this dashboard: https://dune.xyz/kevdnlol/Transaction-Breakdown
The author has included the parameters wallet address, start date and end date in this Dashboard.
Drill down into the single pools of Barnbridge's Smart Yield Product: https://dune.xyz/0xBoxer/Barnbridge-or-Smart-Yield
The Author has chosen to make the parameter poolsymbol into a drop down list here. This allows for easy access to all the relevant pools and detailed statistics on those.
Find out how many people are participating in Yearn Vaults: https://dune.xyz/msilb7/Yearn-How-Many-Addresses-are-Participating
Find out how your investment in $KLIMA is doing:

Summary

Parameters allow you to make a certain part of your SQL query dynamic and thereby offer you to make queries and dashboards interactive. That way you can easily display detailed data on your dashboard since it allows the viewer to customize the dashboard for his needs. You could think of parameters like filters, but the possibilities of using this feature go beyond that.
Last modified 1mo ago