← Back

Post Thread

Level of Detail calculations are now available in #Snowflake Semantic Views:


CREATE OR REPLACE SEMANTIC VIEW sales_sv
FACTS (
  -- Counts orders at customer grain,
  -- regardless of the query grain.
  orders_per_customer
    AS COUNT(orders.order_id)
      FIXED DIMENSIONS (customers.customer_id),
  -- Sums revenue at customer grain,
  -- regardless of the query grain.
  revenue_per_customer AS
    SUM(orders.order_amount)
      FIXED DIMENSIONS (customers.customer_id),
)

METRICS (
  avg_orders_per_customer AS AVG(orders_per_customer),
  avg_revenue_per_customer AS AVG(revenue_per_customer),
  avg_basket_size AS
    AVG(SUM(order_items. line_total)
      INCLUDE DIMENSIONS (orders.order id))

);

https://docs.snowflake.com/...c/sql#label-semantic-views-lod

docs.snowflake.com

Using SQL commands to create and manage semantic views | Snowflake Documentation

0 Replies
0 Reposts