When to use definitions
Use definitions for SQL that should stay consistent across your workspace:- Business metrics: Monthly recurring revenue, activation rate, churn, retention, pipeline coverage
- Reusable models: Cleaned accounts, eligible users, active subscriptions, qualified pipeline
- Shared filters: Exclude test accounts, internal domains, trials, deleted records, or sandbox data
- Complex joins: Package multi-table logic that many charts or agents need to reuse
Where to find definitions
- Go to the Data page.
- Select a data source.
- Open the Definitions section above the table list.
- Click Create definition to start a new definition.
Create a definition
When you create or edit a definition, add:- Name: A human-readable label, such as “Monthly recurring revenue”
- Reference name: A SQL-safe name, such as
mrr - Description: A short explanation of what the definition represents
- SQL query: The read-only SQL Basedash should expand wherever the definition is referenced
Use definitions in SQL
Reference a definition with Liquid syntax:AI and definitions
Basedash gives AI agents a catalog of available definitions for the data sources they are using. The AI can:- Reference definitions when writing SQL for charts, dashboards, chat, insights, and automations
- Inspect a definition’s SQL before using or editing it
- Create new definitions when you ask for a reusable metric, model, or SQL definition
- Update existing definitions when you ask to change the underlying logic
Version history
Every SQL or description change creates a new definition version. Open Query history from a definition to review earlier versions and restore a previous one. Version history is useful when a metric changes, a query needs to be audited, or you want to understand why a dashboard’s calculation changed over time.Permissions
Organization admins can create, edit, delete, and restore definitions. Members with data source access can view and run definitions, but cannot change them. Deleting a definition can break charts, dashboards, or queries that reference it. Before deleting a definition, check where it is used and update dependent queries.Best practices
- Keep each definition focused on one metric, model, or reusable concept.
- Write stable reference names because queries use them directly.
- Add descriptions that explain the business meaning, not just the SQL mechanics.
- Use CTEs when referencing definitions from larger queries.
- Prefer definitions for deterministic calculations and AI context or skills for prose guidance.
- Avoid cross-source assumptions: definitions only work within their own data source.