# Metrics Tree > A hierarchical tree visualization that maps how your key metrics break down and relate to each other, from a North Star metric down to its component drivers. Visualize how your metrics break down from a North Star into its underlying drivers. Makes metric dependencies and relationships easy to scan for your whole team. **Best for**: KPI decomposition, metric dependency mapping, business driver analysis **Key techniques**: `col_totals` for aggregated values, CSS Grid multi-level layout, pseudo-element connectors :::tip Sparklines coming soon We're working on a sparkline component that will let you embed inline trend charts inside each node. Once available, you'll be able to show how each metric is trending right alongside its current value. ::: ## Template Code ```html
North Star {{ col_totals.`North Star`.formatted }} Primary outcome
Revenue {{ col_totals.`Revenue` }} Money from customers
Cost {{ col_totals.`Cost` }} Money paid out
Buyers {{ col_totals.`Buyers` }} People who purchased
AOV {{ col_totals.`Aov` }} Avg order value
COGS {{ col_totals.`Cogs` }} Cost to make
Shipping {{ col_totals.`Shipping` }} Cost to deliver
Sessions {{ col_totals.`Sessions` }} Traffic
Conversion Rate {{ col_totals.`Conversion Rate` }} Sessions → buyers
``` ## How It Works The tree is built with pure CSS Grid. No JavaScript needed. Each level is a grid row, and connector lines between levels are drawn using CSS pseudo-elements (`:before` and `:after`). **Layout structure:** - Each level (`level-1` through `level-4`) is a CSS Grid with a set number of columns - Between levels, a `.lines` row draws the branching connectors - Empty `.empty` divs act as spacers to position nodes correctly under their parent **Data access:** - All values use `col_totals` to pull aggregated totals across the entire dataset - This means the tree shows a single rolled-up number per metric, not row-by-row data ## Required Data Fields | Field | Type | Slot | Description | |-------|------|------|-------------| | `Month` | Dimension | Row | Time dimension for aggregation | | `North Star` | Measure | Value | Top-level metric (e.g., Profit) | | `Revenue` | Measure | Value | Revenue metric | | `Cost` | Measure | Value | Total cost metric | | `Buyers` | Measure | Value | Number of buyers | | `Aov` | Measure | Value | Average order value | | `Cogs` | Measure | Value | Cost of goods sold | | `Shipping` | Measure | Value | Shipping costs | | `Sessions` | Measure | Value | Number of sessions | | `Conversion Rate` | Measure | Value | Sessions-to-buyers conversion rate | ### Setting Up the Block In the Visualization Block definition, add the time dimension as a **Row** field and all metrics as **Value** fields with `aggregation: 'sum'`. Enable **Show Column Total** in the block settings. the template reads from `col_totals` to display the aggregated values. ## Sample Data Import this data into Holistics to use: [sample-data-metrics-tree.csv](https://media.holistics.io/eb208343-metrics-tree.csv) ```csv Month,North Star,Revenue,Cost,Buyers,AOV,COGS,Shipping,Sessions,Conversion Rate 2024-01,245149,352188,107039,7322,48.1,79692,27347,239226,0.0306 2024-02,265628,382769,117141,7996,47.87,86680,30461,262095,0.0305 2024-03,299244,431517,132273,9020,47.84,97050,35223,290974,0.031 2024-04,335063,482296,147233,9769,49.37,107089,40144,318913,0.0306 2024-05,342112,490557,148445,9774,50.19,107249,41196,339084,0.0288 2024-06,343323,489927,146604,9597,51.05,105620,40984,346630,0.0277 2024-07,320203,454882,134679,8921,50.99,97219,37460,340021,0.0262 2024-08,293177,415243,122066,8038,51.66,88673,33393,321534,0.025 2024-09,274734,388849,114115,7574,51.34,83640,30475,296710,0.0255 2024-10,250143,354674,104531,7061,50.23,77305,27226,272909,0.0259 2024-11,239129,340346,101217,6811,49.97,75343,25874,257353,0.0265 2024-12,250370,358061,107691,7203,49.71,80355,27336,255162,0.0282 ``` ## Customization Tips ### Adapt the tree to your metrics This template uses an e-commerce profit tree as an example, but you can adapt it to any metric hierarchy. Replace the metric names, labels, and subtexts to match your business: - **SaaS**: MRR → New MRR + Expansion - Churn → Leads × Conversion Rate - **Marketplace**: GMV → Buyers × AOV → Traffic × Conversion × Average Basket - **Content**: Engagement → Views × Time on Page → Impressions × CTR ### Change node colors The `.pos` and `.neg` classes add green and red accent borders. Adjust the colors or add new classes: ```css .metric-tree-v1 .pos { border-color: rgba(16, 185, 129, 0.35); /* green */ } .metric-tree-v1 .neg { border-color: rgba(239, 68, 68, 0.35); /* red */ } /* Add a neutral accent */ .metric-tree-v1 .neutral { border-color: rgba(59, 130, 246, 0.35); /* blue */ } ``` ### Add or remove levels To add a 5th level, create a new `.level-5` grid rule and a `.lines-4` connector row: ```css .metric-tree-v1 .level-5 { grid-template-columns: repeat(6, var(--double-w)); } .metric-tree-v1 .lines-4 { grid-template-columns: repeat(5, var(--double-w)); } ``` Then add the corresponding HTML for the new nodes and connectors. ### Adjust node sizing The node width is controlled by a single CSS variable. Change the `clamp()` values to make nodes wider or narrower: ```css --node-w: clamp(100px, 12vw, 150px); /* min, preferred, max */ ```