Say I have the following semantic model and metrics:
semantic_models:
- name: property_snapshot_f
defaults:
agg_time_dimension: calendar_date
description: |
Property Daily Snapshot fact model
model: ref('orders')
entities:
- name: tribeca_id
type: foreign
- name: cohort_key
type: foreign
measures:
- name: property_count # Unique property count
expr: tribeca_id
agg: count_distinct
primary_entity: prop_snapshot
dimensions:
- name: calendar_date
expr: cast(calendar_date as date)
type: time
type_params:
time_granularity: day
- name: property_type
type: categorical
- name: properties_d
defaults:
agg_time_dimension: stabilization_date
description: |
Property Dimension model
model: ref('orders')
entities:
- name: tribeca_id
type: primary
- name: address
type: foreign
- name: property_manager
type: foreign
- name: stage
type: foreign
- name: purchase_date
type: foreign
- name: management_date
type: foreign
- name: management_end_date
type: foreign
- name: sold_date
type: foreign
measures:
- name: property_count1 # Unique property count
expr: tribeca_id
agg: count_distinct
dimensions:
- name: stabilization_date
expr: cast(stabilization_date as date)
type: time
type_params:
time_granularity: day
- name: fund
type: categorical
- name: unit_status
type: categorical
- name: property_management_date
type: categorical
- name: market
type: categorical
metrics:
- name: managed_homes_count
description: No of Managed Homes
type: simple
label: Managed Homes Count
type_params:
measure: property_count
filter: |
({{Entity('address')}} is not null and {{ Dimension('tribeca_id__fund') }} NOT LIKE '%DBC%') and ({{ Dimension('tribeca_id__market') }} NOT LIKE '%DBC%') and ({{ Entity('cohort_key') }} NOT LIKE '%DBC%')
If I try to reference {{Entity('address')}} in the filter I get an error. I need to add the entity path to get this to work i.e ({{Entity('address',['tribeca_id'])}}. If I try to use dunders I also get an error : ParseWhereFilterException("Entity name is in an incorrect format: 'tribeca_id__address'. It should not contain any dunders (double underscores, or __)."))].
We should be able to reference an entity in the where filter without needing to provide the entity path i.e {{Entity('address')}}
Describe alternatives you've considered
I can use the entity path syntax, but this is inconsistent with how we reference primary entities.
Who will this benefit?
This helps developers be more efficient and consistent when writing metric definitions.
Describe the feature
Say I have the following semantic model and metrics:
If I try to reference
{{Entity('address')}}
in the filter I get an error. I need to add the entity path to get this to work i.e({{Entity('address',['tribeca_id'])}}
. If I try to use dunders I also get anerror : ParseWhereFilterException("Entity name is in an incorrect format: 'tribeca_id__address'. It should not contain any dunders (double underscores, or __)."))].
We should be able to reference an entity in the where filter without needing to provide the entity path i.e
{{Entity('address')}}
Describe alternatives you've considered
I can use the entity path syntax, but this is inconsistent with how we reference primary entities.
Who will this benefit?
This helps developers be more efficient and consistent when writing metric definitions.
From SyncLinear.com | SL-1610