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
+36-3Lines changed: 36 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,17 @@ 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
+
type: "number"
135
+
options:
136
+
- 1000
137
+
- 5000
138
+
- 10000
139
+
default: 5000
140
+
126
141
# Parameter with options from a dimension
127
142
department:
128
143
label: "Department"
@@ -183,7 +198,24 @@ models:
183
198
184
199
In this example, the `filtered_revenue` dimension will only show revenue for the regions selected in the `region` parameter.
185
200
186
-
### Example 2: Using parameters in table joins
201
+
### Example 2: Using numeric parameters in dimension SQL
202
+
203
+
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.
217
+
218
+
### Example 3: Using parameters in table joins
187
219
188
220
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
221
@@ -288,9 +320,10 @@ SELECT
288
320
FROM orders
289
321
WHERE region IN (${lightdash.parameters.region})
290
322
AND order_date >= ${lightdash.parameters.date_range}
323
+
AND revenue >= ${lightdash.parameters.min_revenue}
291
324
```
292
325
293
-
This query will filter orders by the regions selected in the `region` parameter and by the date selected in the `date_range` parameter.
326
+
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
327
295
328
## Saving parameter values at chart and dashboard levels
0 commit comments