|
| 1 | +--- |
| 2 | +description: >- |
| 3 | + Parameters are an easy way to make an interactive dashboard or query in which |
| 4 | + multiple parameters/variables can change. |
| 5 | +--- |
| 6 | + |
| 7 | +# Parameters |
| 8 | + |
| 9 | +### What are Parameters? |
| 10 | + |
| 11 | +Parameters allow you to make changes to certain defined parameters of your code with a few simple clicks. 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. |
| 12 | + |
| 13 | +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. |
| 14 | + |
| 15 | +Parameters in a Dashboard can be shared between different queries, just make sure to use the same name between all of them. |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +### How to use Parameters? |
| 24 | + |
| 25 | +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}}`. |
| 26 | + |
| 27 | +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 and change the type of the parameter. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +### Example Query |
| 32 | + |
| 33 | +This query returns the running total of Gas Paid in USD. |
| 34 | + |
| 35 | +The Query Author has chosen to include a parameter for `wallet address`, `start date` and `end date`. |
| 36 | + |
| 37 | +```sql |
| 38 | +with alltransactions |
| 39 | +AS ( |
| 40 | +SELECT |
| 41 | + block_time, |
| 42 | + success, |
| 43 | + gas_price/10^9 AS gas_prices, |
| 44 | + gas_used, |
| 45 | + (gas_price*gas_used)/10^18 AS eth_paid_for_tx, |
| 46 | + hash |
| 47 | +FROM ethereum.transactions |
| 48 | +WHERE "from" = CONCAT('\x', substring('{{1. Eth Address}}' from 3))::bytea |
| 49 | +AND block_time >= '{{2. Start Date}}' |
| 50 | +AND block_time < '{{3. End Date}}') |
| 51 | + |
| 52 | +SELECT |
| 53 | + date_trunc('minute', block_time), |
| 54 | + SUM(eth_paid_for_tx*price) over (ORDER BY date_trunc('minute', block_time)) AS "Total Gas Fees Paid in USD" |
| 55 | +FROM alltransactions |
| 56 | +LEFT JOIN |
| 57 | + (SELECT |
| 58 | + minute, |
| 59 | + price |
| 60 | + FROM prices.usd |
| 61 | + WHERE |
| 62 | + symbol = 'WETH' AND |
| 63 | + minute > '{{2. Start Date}}') AS prices |
| 64 | +ON date_trunc('minute', block_time) = minute |
| 65 | +ORDER BY block_time DESC |
| 66 | +``` |
| 67 | + |
| 68 | +Find this query [here](https://duneanalytics.com/queries/64430/128463) |
| 69 | + |
| 70 | +### **Example Dashboards** |
| 71 | + |
| 72 | +**Find interesting stats on Ethereum Wallets with this dashboard:** |
| 73 | +[https://duneanalytics.com/kevdnlol/Transaction-Breakdown](https://duneanalytics.com/kevdnlol/Transaction-Breakdown) |
| 74 | + |
| 75 | +_The author has included the parameters `wallet address`, `start date` and `end date` in this Dashboard._ |
| 76 | + |
| 77 | +**Drill down into the single pools of Barnbridge's Smart Yield Product:** |
| 78 | +[https://duneanalytics.com/0xBoxer/Barnbridge-or-Smart-Yield](https://duneanalytics.com/0xBoxer/Barnbridge-or-Smart-Yield) |
| 79 | + |
| 80 | +_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._ |
| 81 | + |
| 82 | +**Find out how many people are participating in Yearn Vaults:** |
| 83 | +[https://duneanalytics.com/msilb7/Yearn-How-Many-Addresses-are-Participating](https://duneanalytics.com/msilb7/Yearn-How-Many-Addresses-are-Participating) |
| 84 | + |
| 85 | +### Summary |
| 86 | + |
| 87 | +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. |
| 88 | +You could think of parameters like filters, but the possibilities of using this feature go beyond that. |
| 89 | + |
0 commit comments