Skip to main content
Tables in Lightdash are built from dbt models (either one, or many joined together).

Adding Tables to your project

Tables come from dbt models that have been defined in your dbt project’s schema.yml files. If your dbt model has been defined in a YAML file, and has at least one column documented, it will appear in Lightdash as a table. For example, if we had this in our schema.yml files in dbt, we’d see a Table called Users in Lightdash.
You can read more about adding Tables to Lightdash here.

Table configuration

You can customize how Tables look in Lightdash by adding configuration to your YAML file. Here’s an example of most the properties you can use when defining a Table:

Table properties

PropertyValueNote
labelstringCustom label. This is what you’ll see in Lightdash instead of the Table name.
order_fields_byindex or labelHow the fields will be sorted in the sidebar. Read about the order rules.
joinsarrayJoin logic to join other data models to the Table. Read about joins.
metricsobjectModel metrics. Read about model metrics
groupsarray of stringsGroup tables in the sidebar, with up to 5 levels of nesting. Read about groups.
group_labelstringDeprecated: use groups instead. Group tables in the sidebar.
sql_fromstringOverrides dbt model relation_name
sql_filterstringA permanent filter that will always be applied when querying this table directly. Read about sql_filter.
sql_wherestringAlias for sql_filter
required_attributesobjectLimits access to users with those attributes (AND logic). Read about user attributes
any_attributesobjectLimits access to users with those attributes (OR logic). Read about user attributes
group_detailsobjectDescribes the groups for dimensions and metrics
default_filtersarrayDimension filters that will be applied when no other filter on those dimension exists. Read about default_filters
default_show_underlying_valuesarrayDefault fields shown in “View underlying data” for all metrics in this model. Read about default_show_underlying_values
exploresobjectAllows you to define multiple table explores in Lightdash from a single dbt model.
parametersobjectModel-level parameters that can be referenced in SQL properties. Read about parameters
setsobjectAllows you to define a reference to a collection of fields. This reference can be re-used throughout the model.
case_sensitivebooleanIf set to false, string filters on dimensions in this table will be case insensitive by default. Defaults to true.

Adding a new dbt model

If you’ve added a new dbt model to your project, you need to do dbt run + dbt refresh before it will appear in Lightdash. Lightdash gets information about your data models from dbt. But it gets information about the data generated by those data models from your data warehouse. This means that if you add a new dbt model to your project or update a model so that you’re making changes to the table it generates, then you need to do two things before your changes will appear in Lightdash:
  1. Materialize the new table or changes using dbt run. You want the data in your data warehouse to be the new table you’re expecting. So you need to do dbt run to update the table from the data model you just changed.
  2. Click Refresh dbt in Lightdash or run lightdash refresh in the CLI. This will re-sync your dbt project in Lightdash so that changes you made to your dbt models are shown in Lightdash (e.g. adding a new table or column).

Order fields by

By default, the fields in your sidebar for any table will appear alphabetically (order_fields_by: "label"). Sometimes, you might not want your fields to appear alphabetically, but instead, in the same order as they are in your YAML file. You can achieve this by setting the order_fields_by parameter in your table’s meta tag to index, like this:
So, in the example above, the fields in the sidebar for “My Table” would appear in the order:
  • user_id
  • user_name
  • user_email
Instead of being listed alphabetically. Here are some other things worth mentioning about the order_fields_by parameter:
  • By default, order_fields_by is set to label, which means that your fields will appear in the table listed alphabetically.
  • Since metrics can be declared in multiple places within your YAML (as a dbt metric, in the model meta tag, under a dimension’s meta), we force the following order on metrics if you set order_fields_by to index:
    • dbt metrics appear first
    • then, metrics defined in the model’s meta
    • then, metrics defined in the dimensions’ meta
  • Group labels inherit the index of the first dimension that use them.

Groups

Use groups to organize tables into nested groups in the sidebar. You can nest up to 5 levels deep by passing an array of group keys, ordered from outermost to innermost.
In the example above, the users table is placed under the mobile group, and within it, the engagement subgroup. Group keys are referenced project-wide. Define their display labels and (optional) descriptions in your lightdash.config.yml file under table_groups:
If a group key is not defined in table_groups, the key itself is used as the label. The tables in your sidebar will appear in the following order:
  • Grouped tables appear first, with groups sorted alphabetically by label
  • Ungrouped tables appear after the grouped tables, alphabetically
  • Tables within each group are also ordered alphabetically
The groups property replaces the legacy group_label property. group_label still works for backwards compatibility but is deprecated — migrate to groups for nested group support.

SQL from

sql_from is a configuration option that overrides the default dbt model relation name when generating SQL queries in Lightdash. For example, you might use this if you want your Lightdash explore to query from a specific materialized view, a different schema, or include additional SQL logic in the FROM clause while still maintaining the dbt model structure for dimensions and metrics.

SQL filter (row-level security)

sql_filter adds a filter to the table that cannot be removed in Lightdash. It is automatically added to the compiled SQL when running queries. For example:
Any queries that I run using the Sales table in Lightdash will always have a filter for sales_region = 'EMEA' in their compiled SQL
Row-level security using user attributes
Using sql_filter with user attributes allows you to set up row-level security in your tables. You can reference user attributes in your sql_filter using ${lightdash.attributes.my_attribute_name} For example:
sql_filter will only be applied when querying tables directly.
For example:
  • Table A is joined to Table B
  • Table B has a sql_filter applied to it
  • A user queries Table A and adds a field from the joined table (Table B) to their query
  • the sql_filter from Table B will not be applied to the query (you would need to add this as a sql_filter to Table A directly for it to apply)
If you reference a dimension from a joined table in your sql_filter, the referenced table will always be joined in your queries.
For example:
  • You have Table A which is joined to Table B
  • In Table A, you’ve added a sql_filter: ${TABLE}.sales_region = 'EMEA' OR ${table_b}.sales_region IS NULL
  • Table B will always be joined to Table A in your queries (even if there are no fields from Table B selected in your results table)

Required attributes

Lightdash can use 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.
If a user without access to this table runs a query that contains this table, they will get a Forbidden error.

Any attributes

While required_attributes uses AND logic (all conditions must match), any_attributes uses OR logic — a user only needs to match at least one condition.
You can combine required_attributes and any_attributes on the same table. When both are set, both checks must pass. See user attributes for details.

Defining primary keys

You can specify a primary key for your model to uniquely identify each row. This is important for tables as it helps Lightdash understand the relationships between tables and prevent data duplication, especially when dealing with SQL fanouts in joins. The primary key can be defined in two ways:

Single column primary key

If your table has a single column that uniquely identifies each row, you can define it as a string:

Complex primary key

If your table requires multiple columns to uniquely identify each row, you can define the primary key as an array of strings:
Using a properly defined primary key helps Lightdash optimize queries and provide accurate results when working with joined tables. It’s especially important for preventing metric inflation in SQL joins where duplicate rows can lead to incorrect aggregations.

Default show underlying values

You can set a default show_underlying_values configuration at the model level that applies to all metrics in that model. This is useful when you want consistent underlying data visibility across all metrics without repeating the same configuration for each metric. Individual metrics can override the model-level default by specifying their own show_underlying_values.
The list of fields must be dimension names (or metrics if you’d like to include them) from the base table or from any joined tables. To reference a field from a joined table, prefix the field name with the joined table name, like this: my_joined_table_name.my_dimension. The order that the fields are listed in default_show_underlying_values is the order that they’ll appear in on the “View underlying data” table.

Default filters

Use default_filters to define filters on Dimensions that will be applied when no other user-defined filter on those Dimensions exists. Default filters will apply to tables on load and can be populated with a pre-determined value. Use them to suggest to users the kind of filters they might want to consider, or provide a default filtered view of a table that can be changed if needed. An optional required flag can be added, and if this flag is set to required: true, the filter for this field cannot be removed from the UI but users can still modify the operator and value to adjust how this filter is applied to the data. This ensures the filter is always applied in some form, while giving users flexibility to change the date range or other values. This can be particularly useful if you have a large table and want to force users to filter on a partitioned date. In contrast, when required: false (or omitted), the filter is pre-populated but fully editable — users can change the field, operator, value, or remove it entirely. default_filters and required_filters can only target dimensions (including visible additional_dimensions). Hidden dimensions (hidden: true) are not valid targets and will fail compilation. Below you can see there is a default filter with the optional required flag, that will have show the last 14 days of data by default.
Note: Required filters are not a security feature. For secure data access control, use user attributes.

If you have many filters in your list, they will be joined using AND

In the example above, the orders table will have a default filter of date in the past 14 days and status completed. Both can be removed by the user, as the required flag is not present. Note that we do also support a legacy structure for defining required filters, see below:

Available filter types

OperatorDescriptionExample (as code)Supported Types
isValue is equal touser_name: "katie"String, Number, Date
is notValue is not equal touser_name: "!katie"String, Number, Date
betweenValue is between two values (inclusive)age: "between 18 and 65"Number, Date
order_date: "between 2024-01-01 and 2024-12-31"Number, Date
containsString contains valueuser_name: "%katie%"String
does not containString does not contain valueuser_name: "!%katie%"String
starts withString starts with valueuser_name: "katie%"String
ends withString ends with valueuser_name: "%katie"String
is greater thanNumber is greater than valuenum_orders: "> 4"Number
is greater than or equal toNumber is greater than or equal to valuenum_orders: ">= 4"Number
is less thanNumber is less than valuenum_orders: "< 4"Number
is less than or equal toNumber is less than or equal to valuenum_orders: "<= 4"Number
in the pastDate is before x (days / months / years)date: "inThePast 14 days"Date
in the nextDate is after x (days / months / years)date: "inTheNext 30 days"Date
is nullValue is NULLstatus: "null"All
is not nullValue is not NULLstatus: "!null"All
is emptyValue is empty stringnotes: "empty"String
is not emptyValue is not empty stringnotes: "!empty"String
is [boolean]Boolean value is trueis_complete: "true"Boolean
is not [boolean]Boolean value is false or nullis_complete: "!true"Boolean
in listValue is in a list of valuesstatus: ["active", "pending", "approved"]String, Number

Filter examples

Between operator (numeric):
Between operator (dates):
Multiple values (list): Use an array to filter by multiple values. This generates a SQL IN clause, e.g. WHERE status IN ('active', 'pending', 'approved').
Pattern matching:
Date intervals:
Available intervals: milliseconds, seconds, minutes, hours, days, weeks, months, years Complex example with multiple filters:

Filter notes

  • Case insensitivity: Keywords like between, AND, null, empty are case-insensitive
  • Quotes: Use quotes for strings with spaces or special characters
  • Escaping: Use ^ to escape special characters (%, _, ,, !, ^)
  • AND logic: Multiple filters are automatically joined with AND
  • Priority: Default filters only apply when no user-specified filter exists for that dimension
  • Supported fields: default_filters and required_filters apply to dimensions only (not metrics)
  • Hidden fields: Hidden dimensions (hidden: true) cannot be used in default_filters/required_filters

Case sensitive

You can control whether string filters are case sensitive or case insensitive at the table level. By default, all string filters are case sensitive (case_sensitive: true). When set to false, string filters on all dimensions in this table will ignore case differences when matching values. This setting affects the following string filter operators: equals, not equals, starts with, ends with, includes, and doesn't include.
With case_sensitive: false, filtering for “john” on any string dimension would match “John”, “JOHN”, “john”, etc.
Table-level case_sensitive settings override the project-level default. Dimension-level settings override both. See Dimensions reference for dimension-level configuration and lightdash.config.yml reference for project-level defaults.

Parameters configuration

The parameters section allows you to define model-level parameters that can be referenced in various parts of your model’s SQL properties. These parameters are scoped to the specific model where they’re defined.
Each parameter is defined as a key-value pair where the key is the parameter name (must be alphanumeric with underscores or hyphens) and the value is an object with the following properties:
PropertyRequiredValueDescription
labelYesstringA user-friendly label for the parameter as it will be displayed in the UI.
descriptionNostringA description of the parameter.
typeNo”string” or “number”The type of the parameter. Defaults to “string” if not specified.
optionsNoArray of strings, numbers, or { label, value } objectsA list of possible values for the parameter.
defaultNostring, number, or Array of strings/numbersThe default value(s) for the parameter. When using labeled options, the default must match a value, not a label.
multipleNobooleanWhether the parameter input will be a multi-select.
allow_custom_valuesNobooleanWhether users can input custom values beyond predefined options.
options_from_dimensionNoObjectGet parameter options from a dimension in a model. Requires model and dimension arguments (see below).
If using options_from_dimension, the object requires the following properties:
PropertyRequiredValueDescription
modelYesstringThe model containing the dimension.
dimensionYesstringThe dimension to get options from.

Labeled options

Static options can be authored as either plain values or { label, value } objects.
Plain string/number arrays continue to work and remain the simplest form when the label and value are the same.

Using model-level parameters

Model-level parameters are referenced with the model name included in the syntax: ${lightdash.parameters.model_name.parameter_name} or the shorter alias ${ld.parameters.model_name.parameter_name}. For example, to reference a parameter named region from the current model:
Or using the shorter alias:

Using parameters from joined tables

You can also reference model-level parameters from joined tables. This is particularly useful when you want to use parameters defined in one model while working in another:
In this example, the join condition references a model-level parameter customer_status that is defined in the customers model, even though we’re configuring the orders model. See the Parameters guide for more examples and information on how to use parameters.

Explores

You can define multiple table explores from a single table using the explores config. This will allow you to list the same dbt model multiple times in the list of Tables in Lightdash. You can use it to show different versions of a table, join different tables to the base table, customize table visibility, etc. Below is an advanced example of using Explores. This will result in three total tables using the deals model at the base.
  • Deals will not have any joins or limitations
  • Deals w/Accounts will join to the accounts table and show all Accounts fields, but only people with the is_exec user attribute can see it
  • Deals w/Accounts (no Names) will join to the accounts table and only show Industry and Segment dimensions, it has no access restrictions
All the table configuration options can be used under the explores tag. Read this guide to learn more about explores

Sets

Sometimes you may find that you’re redeclaring the same set of fields for things like joins and show_underlying_values. In this case, you can define a set. A set allows you to associate those fields to a single value. That reference can then be used any place you would normally define fields.

Expand

The expand operator (ex. my_set*) tells Lightdash to look up the set being referenced and resolve it to the associated collection of fields. When Lightdash compiles your model, it will replace set reference names with the actual fields.

Exclusions

In the instance where you want to leverage some, but not all fields in a set, you can use the excludes operator (ex. -field_name). The exclusion needs to be used in conjunction with an expand operator. This tells Lightdash to expand a given set while omitting any field name using the exclusion operator.

Joins

Within a model, you may join with other model tables. The sets you define can reference those joined fields as well! Use dot notation to reference a joined table:
Remember, in order to include fields from another table in your set, you need ensure that you have joined the table the set originates from before defining the set.