When would you use this?
- Finance reviews need gross profit; weekly ops meetings need revenue - the same dashboard should serve both without anyone switching reports.
- A CFO wants one governed performance metric that switches between revenue, food cost, and margin depending on the meeting.
- A BI developer is tired of maintaining three nearly identical dashboards for different financial views - they want one dashboard where a filter controls which calculation runs.
- Your semantic layer needs to replicate the behavior of a BI tool parameter: the user picks a value from a list, and a metric’s calculation changes accordingly.
What this recipe builds
In traditional BI tools, a parameter is a user-controlled input that can change a calculation. Users pick a value from a list, and selecting it changes which formula runs behind the scenes. Honeydew implements this through two components working together:- A disconnected parameter entity (
dim_financial_view) that holds the values a BI user can filter on. - The
GET_FIELD_SELECTION()function inside a metric, which reads whatever value the BI user has filtered on and routes to the correct calculation.
Architecture
Steps
1
Create the parameter entity
The
dim_financial_view entity is disconnected - it has no relations to
any other entity. It exists purely to carry the parameter values that a BI
user can filter on. Its dataset is an inline SQL VALUES statement - no
warehouse table is required.- UI
- YAML
- Click Add new entity.
- Choose Custom SQL.
- Paste the following SQL:
- Click Load columns.
- Rename the entity to
dim_financial_view. - Do not set any relations - continue and save.
2
Create the dynamic routing metric (revenue_dynamic)
Create a new metric called
revenue_dynamic. GET_FIELD_SELECTION(entity.attribute, default)
inspects the current query context and returns the value the BI user has
filtered on for dim_financial_view.financial_view. If no filter is applied,
it returns the default ('Gross Profit'). The CASE expression uses that
value to route to the correct existing metric.- SQL
- YAML
How the generated SQL changes
Honeydew compilesGET_FIELD_SELECTION at query time by substituting the
detected filter value directly into the CASE statement:
Sample output
Samerevenue_dynamic metric, 2022, top 5 cities - three different filter
selections show three different numbers:
Routing reference
Using in a BI tool
- Drag
dim_financial_view.financial_viewas a filter. - Select a single value:
Revenue,Food Cost, orGross Profit. - Drag
order_detail.revenue_dynamicto the view. The metric uses the correct formula automatically. Switch the filter value to see the calculation change.
Key design notes
Related reading
- Metrics - reference for metrics that change behavior based on user filters
- Conditional filtering - deeper reference
on
GET_FIELD_SELECTIONpatterns - Entities - reference for disconnected entities