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
+55Lines changed: 55 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,61 @@ Parameters can be referenced in many places throughout your Lightdash project:
44
44
7.**Additional Dimensions**: Use parameters in the SQL definition of an [additional dimension](/references/dimensions#additional-dimensions)
45
45
8.**Custom Dimensions**: Use parameters in [custom dimension](/references/custom-fields#custom-sql) definitions
46
46
47
+
## Parameter types
48
+
49
+
Parameters in Lightdash support different data types to help you work with various kinds of data. By default, all parameters are treated as strings, but you can convert them to other types as needed.
50
+
51
+
### Supported parameter types
52
+
53
+
Lightdash officially supports the following parameter types:
54
+
55
+
-**String** (default): Text values
56
+
-**Number**: Numeric values (integers and decimals)
57
+
58
+
### Type conversion workarounds
59
+
60
+
While not officially supported yet, you can work around for other data types via SQL type casting.
61
+
To convert a parameter to a specific type, use the `::` syntax followed by the type name:
62
+
63
+
```sql
64
+
${lightdash.parameters.parameter_name}::type
65
+
```
66
+
67
+
<Note>
68
+
The type conversion happens at the SQL level, so the available types depend on your database system (PostgreSQL, BigQuery, Snowflake, etc.). Common types like `integer`, `numeric`, `date`, `timestamp`, and `boolean` are supported across most databases.
69
+
</Note>
70
+
71
+
#### Date conversion
72
+
73
+
As a workaround, you can use `::date` for dates or `::timestamp` for datetime values:
74
+
75
+
```sql
76
+
-- Convert to date (workaround)
77
+
WHERE ${TABLE}.order_date >= ${lightdash.parameters.start_date}::date
78
+
79
+
-- Convert to timestamp (workaround)
80
+
WHERE ${TABLE}.created_at >= ${lightdash.parameters.start_datetime}::timestamp
81
+
```
82
+
83
+
#### Boolean conversion
84
+
85
+
As a workaround, you can use `::boolean` to convert string values like "true"/"false" to boolean:
86
+
87
+
```sql
88
+
-- Convert to boolean (workaround)
89
+
WHERE ${TABLE}.is_active = ${lightdash.parameters.active_only}::boolean
90
+
```
91
+
92
+
#### Other type conversions
93
+
94
+
You can use any SQL type conversion that your database supports:
95
+
96
+
```sql
97
+
-- Convert to specific database types
98
+
WHERE ${TABLE}.category_id = ${lightdash.parameters.category}::uuid
99
+
WHERE ${TABLE}.amount = ${lightdash.parameters.amount}::decimal(10,2)
0 commit comments