Measures
Measures are reusable and governed components that define how an entity or a data asset should be aggregated.
Lynk applies the measure logic in two scenarios:
- Once a feature of type metric is created or consumed 
- Once aggregating (rolling-up) an entity by some of it's features and using the MEASURE() function 
Defining Measures
Measures are definitions of how aggregate functions should be applied to features and fields
# db_prod.core.orders.yml
measures:
- name: total_order_amount
  description: sum of order amount
  sql: sum({total_amount})Name
NameGive the measure a name. This will be used when creating metric features and also will be shown on the Studio UI. It is recommended to give measures informative names that indicate their purpose.
Description [optional]
Description [optional]Describe the measure. It is recommended to give measures informative names that indicate their purpose - for other team members to be able to reuse the measure and for AI apps as well.
SQL
SQLThe measure definition. It should be composed of an aggregate function and a field. It is possible to chain multiple aggregate functions and / or multiple fields, just like you would do on plain SQL when needed.
Some more examples:
# db_prod.core.orders.yml
measures:
- name: count_orders
  description: count of orders
  sql: count(1)
- name: total_order_amount
  description: sum of order amount
  sql: sum({total_amount})
- name: successful_order_amount
  description: sum of successful orders amount
  sql: sum(IFF({order_status} = 'success', {total_amount}, 0))Last updated
