Documentation Index
Fetch the complete documentation index at: https://honeydew.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Goal
Conditional Filtering lets the semantic layer detect and respond to filters coming from a BI tool or an AI agent, so that metric logic can adapt dynamically to the user’s query context. So, instead of blindly applying the same transformation or metric calculation every time, the semantic logic can take into consideration the filters the user provided (likeregion = Europe, or date >= 2024-01-01).
That allows to create default data filtering, and to adjust business logic based on user intent.
Syntax
- Single field (
entity.field) to detect user filters on - Default value expression in case no user filters on
entity.fieldwere provided. If not set, the default value isNULL.
- The filter value if the BI or AI query filtered
entity.filterto a single value, i.e. For the user filterentity.field = 'value', then would returnvalue - The default value if there was no equality filter.
GET_FIELD_SELECTION(entity.field) and a user filter -
The following examples would all return value given the filter for it:
entity.field = 'value'entity.field IN ('value')entity.field = 'value' AND entity.other_field = 'other_value'
NULL (or the default value if set):
entity.field || '' = 'value'entity.field IN ('value', 'other')entity.field = 'value' OR entity.other_field = 'value'entity.field >= 'a'
Use Cases
Change Calculation Based on User Intent
Use the filter a user has supplied to change how a metric is calculated. This is most commonly used to create different metric is calculations at different grains, over the same data. Examples: Dynamic cohorts Given adim_cohort defining user cohorts, simulate based on cohort choice
dim_grain selector entity, choose how a metric is calculated at each grain
(See Metrics with different grains).
Default Filtering
Apply a filter on the data by default, unless a user has instructed otherwise. This is used for:- Reduce Cost & Improve Performance with BI: when users build new BI reports, they would typically send unfiltered queries looking at all the data. They usually don’t want to aggregate all the data, but they may have dragged a metric on a dashboard first and a date filter only after. Default filtering enables to apply a filter on the data until the user decided to change it. For example, force a “last 2 weeks” filter on the big fact tables up until the user explicitly asked for more.
- Ensure Correctness By Removing Duplicated Data: in some data modeling scenarios, data may have multiple versions recorded. Aggregating on the data would result in double counting and a wrong result. Default filtering enables to enforce choosing a specific version of the data, always ensuring there is no double counting.
GET_FIELD_SELECTION with Domain Source Filters.
For example, add a source filter such as
- Default filter for performance filtering
- Default filter for multi-grain data.
- Default filter for slowly changing dimensions