You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/using-parameters.mdx
+35-3Lines changed: 35 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,11 @@ Parameters are variables that you can define once and reference in multiple plac
25
25
- Allow non-technical users to customize queries without writing SQL
26
26
- Save parameter values at the chart and dashboard level
27
27
28
-
For example, you might define a `region` parameter that users can set to filter data by different geographic regions, or a `date_range` parameter that allows users to select different time periods for analysis.
28
+
For example, you might define a `region` parameter that users can set to filter data by different geographic regions, a `date_range` parameter that allows users to select different time periods for analysis, or a `min_revenue` parameter with numeric values that allows users to set revenue thresholds for analysis.
29
+
30
+
<Info>
31
+
**Parameter Types**: Parameters support both string and number values. You can use strings (like `"EMEA"` or `"2023年01月01日"`) or numbers (like `1000` or `5000`) as parameter options.
32
+
</Info>
29
33
30
34
## Where can you reference parameters?
31
35
@@ -123,6 +127,16 @@ parameters:
123
127
default: ["EMEA", "AMER"]
124
128
multiple: true
125
129
130
+
# Parameter with number type
131
+
min_revenue:
132
+
label: "Minimum Revenue"
133
+
description: "Filter for minimum revenue threshold"
134
+
options:
135
+
- 1000
136
+
- 5000
137
+
- 10000
138
+
default: 5000
139
+
126
140
# Parameter with options from a dimension
127
141
department:
128
142
label: "Department"
@@ -183,7 +197,24 @@ models:
183
197
184
198
In this example, the `filtered_revenue` dimension will only show revenue for the regions selected in the `region` parameter.
185
199
186
-
### Example 2: Using parameters in table joins
200
+
### Example 2: Using numeric parameters in dimension SQL
201
+
202
+
You can reference numeric parameters directly without casting:
In this example, the `high_value_orders` dimension will be true for orders with revenue greater than or equal to the numeric `min_revenue` parameter value.
216
+
217
+
### Example 3: Using parameters in table joins
187
218
188
219
You can use parameters in the SQL_ON clause of a table join. This includes both project-level parameters and model-level parameters from the joined table:
189
220
@@ -288,9 +319,10 @@ SELECT
288
319
FROM orders
289
320
WHERE region IN (${lightdash.parameters.region})
290
321
AND order_date >= ${lightdash.parameters.date_range}
322
+
AND revenue >= ${lightdash.parameters.min_revenue}
291
323
```
292
324
293
-
This query will filter orders by the regions selected in the `region` parameter and by the date selected in the `date_range` parameter.
325
+
This query will filter orders by the regions selected in the `region` parameter, by the date selected in the `date_range` parameter, and by orders with revenue greater than or equal to the numeric `min_revenue` parameter.
294
326
295
327
## Saving parameter values at chart and dashboard levels
0 commit comments