With Adhoc Modeling, you can define custom SQL measures and attributes within a given exploration. We call these adhoc measures and adhoc attributes, respectively.
Adhoc measures and attributes can be defined from the data tray:
- Click the
+icon at the top of the measures or attributes list, respectively.
- Define a label and a SQL statement for the adhoc.
Adhoc measures and attributes can used just like any other measure or attribute within the Explore page! They're shown with an orange icon in the data tray to differentiate them from the underlying model attributes.
Note - adhocs are limited to direct usage within explorations only. This means they cannot be applied as dashboard filters, or used with project metrics.
After using an adhoc measure or attribute, you may want to add it to the underlying model. This can be done within the data tray by clicking
... next to the relevant attribute or measure, and clicking
Persist to model.
Adhoc measures and attributes can only be created and updated by users with the
CREATE_OR_UPDATE_ADHOC_MODEL_COLUMNS permission. Explorations with adhoc measures and attributes can still be freely shared with other users, with public links, or embeds. Users will not be able to edit the underlying SQL unless they have permission to do so.
Because adhoc attributes and measures execute SQL against your database, which could potentially read data outside of the current data model, you should only grant this permission to people you trust with access to your database, or if their data access role is configured to restrict their access on the database level. This can be done via Role-Based Database Credentials.