Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bd99f29

Browse files
committed
docs: add number type to parameters
1 parent c082aa2 commit bd99f29

File tree

3 files changed

+55
-7
lines changed

3 files changed

+55
-7
lines changed

‎guides/using-parameters.mdx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ Parameters are variables that you can define once and reference in multiple plac
2525
- Allow non-technical users to customize queries without writing SQL
2626
- Save parameter values at the chart and dashboard level
2727

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>
2933

3034
## Where can you reference parameters?
3135

@@ -123,6 +127,16 @@ parameters:
123127
default: ["EMEA", "AMER"]
124128
multiple: true
125129

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+
126140
# Parameter with options from a dimension
127141
department:
128142
label: "Department"
@@ -183,7 +197,24 @@ models:
183197

184198
In this example, the `filtered_revenue` dimension will only show revenue for the regions selected in the `region` parameter.
185199

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:
203+
204+
```yaml
205+
models:
206+
- name: orders
207+
columns:
208+
- name: high_value_orders
209+
meta:
210+
dimension:
211+
type: boolean
212+
sql: ${TABLE}.revenue >= ${lightdash.parameters.min_revenue}
213+
```
214+
215+
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
187218

188219
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:
189220

@@ -288,9 +319,10 @@ SELECT
288319
FROM orders
289320
WHERE region IN (${lightdash.parameters.region})
290321
AND order_date >= ${lightdash.parameters.date_range}
322+
AND revenue >= ${lightdash.parameters.min_revenue}
291323
```
292324

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.
294326

295327
## Saving parameter values at chart and dashboard levels
296328

‎references/lightdash-config-yml.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ parameters:
136136
- "APAC"
137137
default: ["EMEA", "AMER"]
138138
multiple: true
139+
min_revenue:
140+
label: "Minimum Revenue"
141+
description: "Filter for minimum revenue threshold"
142+
options:
143+
- 1000
144+
- 5000
145+
- 10000
146+
default: 5000
139147
department:
140148
label: "Department"
141149
description: "Filter data by department"
@@ -150,8 +158,8 @@ Each parameter is defined as a key-value pair where the key is the parameter nam
150158
| :----------------------- | :------- | :------------------------- | :---------- |
151159
| `label` | Yes | string | A user-friendly label for the parameter as it will be displayed in the UI. |
152160
| `description` | No | string | A description of the parameter. |
153-
| `options` | No | Array of strings | A list of possible values for the parameter. |
154-
| `default` | No | stringor Array of strings | The default value(s) for the parameter. |
161+
| `options` | No | Array of strings or numbers | A list of possible values for the parameter. |
162+
| `default` | No | string, number, or Array of strings/numbers | The default value(s) for the parameter. |
155163
| `multiple` | No | boolean | Whether the parameter input will be a multi-select. |
156164
| `allow_custom_values` | No | boolean | Whether users can input custom values beyond predefined options. |
157165
| `options_from_dimension` | No | Object | Get parameter options from a dimension in a model. Requires `model` and `dimension` arguments (see below).|

‎references/tables.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ models:
357357
- "APAC"
358358
default: ["EMEA", "AMER"]
359359
multiple: true
360+
min_order_value:
361+
label: "Minimum Order Value"
362+
description: "Filter for minimum order value"
363+
options:
364+
- 100
365+
- 500
366+
- 1000
367+
default: 500
360368
department:
361369
label: "Department"
362370
description: "Filter data by department"
@@ -371,8 +379,8 @@ Each parameter is defined as a key-value pair where the key is the parameter nam
371379
| :----------------------- | :------- | :------------------------- | :---------- |
372380
| `label` | Yes | string | A user-friendly label for the parameter as it will be displayed in the UI. |
373381
| `description` | No | string | A description of the parameter. |
374-
| `options` | No | Array of strings | A list of possible values for the parameter. |
375-
| `default` | No | stringor Array of strings | The default value(s) for the parameter. |
382+
| `options` | No | Array of strings or numbers | A list of possible values for the parameter. |
383+
| `default` | No | string, number, or Array of strings/numbers | The default value(s) for the parameter. |
376384
| `multiple` | No | boolean | Whether the parameter input will be a multi-select. |
377385
| `allow_custom_values` | No | boolean | Whether users can input custom values beyond predefined options. |
378386
| `options_from_dimension` | No | Object | Get parameter options from a dimension in a model. Requires `model` and `dimension` arguments (see below).|

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /