long-metrics-table

Installation
SKILL.md

Skill: Managing Metrics and Dimensions in long-metrics.view.lkml

This document describes the pattern used in long-metrics.view.lkml for defining and aggregating metrics, and provides instructions on how to add new dimensions and measures.

Overview of the Pattern

The file long-metrics.view.lkml implements a long-table format (narrow format) for metrics to allow for flexible reporting. It uses derived tables and UNIONs to stack data for different metrics and timeframes.

  • Base Fields & Aggregation Views: Views with extension: required (like base_fields, day_agg_fields) are used to share common fields across different aggregation levels.
  • Metric Specific Views: Views like metric_total_sale_price compute window functions (running totals, rolling averages) over an explore source (order_items).
  • Combined View: long_metrics uses a derived table with a series of UNION ALL queries to stack data for different metrics and timeframes into a single table. This view handles measures by filtering on a metric dimension.

How-To Guides

Adding a New Dimension from Products or Other Joined Views

If you want to add a new dimension (e.g., category from the products view, which is joined in the order_items explore):

Installs
1
Repository
lkrdev/examples
First Seen
Oct 7, 2026