Last active
July 5, 2026 13:50
-
-
Save Weiyuan-Lane/5309c4e3a9511cd49e6508c6475d4f03 to your computer and use it in GitHub Desktop.
Holistics 4 example - Model with custom SQL for computing overlap with a parameter (linked to a filter)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Model order_items_aggr { | |
| ... | |
| // Query param declaration | |
| param order_date_param { | |
| label: 'Order Created At' | |
| type: 'datetime' | |
| } | |
| query: @sql | |
| with aggr as ( | |
| select | |
| oi.order_id | |
| , count(*) as items_count | |
| from ecommerce.order_items oi | |
| left join ecommerce.orders o on oi.order_id = o.id | |
| {{ order_date_param }} between o.start_date and o.end_date | |
| or {% filter(order_date_param) %} o.start_date {% end %} | |
| group by 1 | |
| ) | |
| select | |
| items_count | |
| , count(*) as orders_count | |
| from aggr | |
| group by 1 | |
| ;; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment