The customer variable is a default variable that’s already created in every dashboard.
It is important to use this variable in every dataset that a panel is built off of if you want it to be customer specific. To configure this, select the field that has your customer’s ID and set it equal to {{customer_id}}
Variables can be used with other operators as well to achieve different filtering needs
Copy
Ask AI
--use the in operator when configuring a multi-select component[[WHERE field1 in {{element1}}]]--filter for similar values using like[[WHERE field_3 LIKE '%' || {{element3}} || '%']]--relative date and number operators[[WHERE field_3 >= {{element3}}]]
In general, it is best to filter tables before joining to other tables, by doing so, you can significantly cut down the calculation and query time needed to compute the entire query.
Example
Copy
Ask AI
--Original QuerySELECT *FROM models_operation INNER JOIN models_flow ON models_flow.resource_ptr_id = models_operation.flow_id INNER JOIN models_datasource ON models_datasource.id = models_operation.data_source_id[[WHERE models_datasource.team_id = {{customer_id }}]];--Improved QuerySELECT *FROM models_operation INNER JOIN models_flow ON models_flow.resource_ptr_id = models_operation.flow_id INNER JOIN (SELECT * FROM models_datasource [[WHERE models_datasource.team_id = {{customer_id }}]] ) AS ds ON ds.id = models_operation.data_source_id;