User attributes provide a way to customise Lightdash charts, dashboards, and other behaviour depending on the user that is logged in. For example, you could only show your sales team members data that are relevant to their region.
${lightdash.attributes.my_attr_1}
- a user attribute called my_attr_1
ld
as an alias for lightdash
attribute
or attr
as an alias for attributes
${lightdash.user.<intrinsic_attribute>}
- reference an intrinsic_attribute
of the current Lightdash user
ld
as an alias for lightdash
email
sql_filter
${lightdash.attributes.<attribute_name> }
. You should use the IN
operator since the attribute might have multiple values.
For example, if you have a user attribute called sales_region
you can use it in your sql like this:
required_attributes
user attributes
to limit some dimensions to some users.
is_admin
attribute true
can use the salary
dimension on user
table.
Forbidden
error. Also, if the user runs a query that contains a metric derived from this dimension, they won’t see the metric on the explore page and won’t be able to query from it.
You can add multiple attributes for a single dimension. There are two ways to do this:
AND
. In the example below, only users with is_admin: "true" AND team_name: "HR"
have access to the salary
dimension in Lightdash.OR
. In the example below, users with team_name = 'HR' OR team_name = 'C-Suite'
have access to the salary
dimension in Lightdash.required_attributes
does not take into account intrinsic attributes of a user - email
.required_attributes
user attributes
to limit some tables to some users.
In the example below, only users with is_admin
attribute true
can use the payments
table. Users without access to this table will not see it on the tables page
or the explore page
when joined to other tables.
required_attributes
does not take into account intrinsic attributes of a user - email
.sql_on
${ lightdash.attributes.<attribute_name> }
. For example, if you have a user attribute called sales_region
you can use it in your sql like this:
table calculations
kiwi
, another group with the attribute value orange
, and they’ve also been assigned as a user to the attribute value coconut
.
tropical_fruits_column
will be visible to them because coconut
is listed in their attribute values ['kiwi','orange', 'coconut']
.
${lightdash.attributes.fruit}
will be replaced with 'kiwi','orange','coconut'
. The final SQL will be my_model.fruit IN ('kiwi','orange','coconut)