> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superjoin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Building Time Trends in Google Sheets with Superjoin

> Capture historical metrics in Google Sheets using Superjoin Workflows and Apps Script to build reliable time series.

<Info>
  This guide helps you automate daily snapshots of key metrics so you can analyze day-over-day, week-over-week, and month-over-month trends—without manual copying.
</Info>

## Demo

<Frame>
  <iframe width="560" height="315" src="https://www.youtube.com/embed/a13cI8exl60?si=Q9XXh8mCxAG9PDN1" title="Superjoin Sequential Refreshes" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen />

  <Caption>Build a dynamic dashboard in Google Sheets with Superjoin</Caption>
</Frame>

***

## Why capture time trends?

When working with live dashboards in Superjoin, data reflects the current state—making it impossible to retrieve metrics from previous days. Capturing daily snapshots lets you:

* Analyze day-over-day, week-over-week, and month-over-month changes
* Build historical trend lines
* Eliminate manual copy-pasting

***

## Prerequisites

<Check>
  Superjoin is installed and your sheet is connected with at least one import set to refresh (manual, scheduled, or via workflow).
</Check>

***

## Overview of the approach

<CardGroup cols={3}>
  <Card title="Live Data" icon="table" iconType="duotone">
    Keep your Superjoin import(s) refreshing to power formulas.
  </Card>

  <Card title="Intermediate Formulas" icon="function" iconType="duotone">
    Centralize key metrics in a middle-layer sheet with formulas.
  </Card>

  <Card title="Daily Snapshots" icon="calendar-days" iconType="duotone">
    Use a workflow + script to paste values into a trends sheet.
  </Card>
</CardGroup>

***

## Step-by-step

<Steps titleSize="h2">
  <Step title="Review your live data setup">
    You should have a Superjoin sheet with live data being refreshed daily, weekly, or monthly. This data represents the state as of when it was last refreshed.

    <Frame>
      <img src="https://usercontent.in.prod.clueso.io/6b101750-ec89-4e66-83bb-0b9079219f65/4bb1a808-c7f1-4860-9974-fe6ac6859e89/88a90d95-1513-47b7-a29b-d19ddf28505a/images/902e18d8-aa0e-414c-a253-a15a4afb2e93.png" />

      <Caption>Pipeline metrics in Google Sheets live-updating with Superjoin integration</Caption>
    </Frame>
  </Step>

  <Step title="Create an intermediate sheet for formulas">
    Establish a separate middle-layer sheet to contain key metric formulas. This acts as a staging area for daily captures before values are overwritten by fresh data. These formulas dynamically reference your Superjoin sheet and stay up-to-date as new data comes in.

    <Frame>
      <img src="https://usercontent.in.prod.clueso.io/6b101750-ec89-4e66-83bb-0b9079219f65/4bb1a808-c7f1-4860-9974-fe6ac6859e89/88a90d95-1513-47b7-a29b-d19ddf28505a/images/24695776-bdad-4531-83f4-9b694c0aa6dd.png" />

      <Caption>Middle-layer sheet containing live formula outputs</Caption>
    </Frame>

    <Note>
      Because these formulas are live, yesterday's values are lost after each update. We'll capture values before they refresh.
    </Note>
  </Step>

  <Step title="Prepare a destination sheet for snapshots">
    Set up a final trends or analysis sheet to collect daily snapshots. You'll automate copying values—not formulas—here, ensuring each day's state is preserved after each refresh.

    <Frame>
      <img src="https://usercontent.in.prod.clueso.io/6b101750-ec89-4e66-83bb-0b9079219f65/4bb1a808-c7f1-4860-9974-fe6ac6859e89/88a90d95-1513-47b7-a29b-d19ddf28505a/images/ea8abe20-04c7-45b7-be48-f5fea0cf386d.png" />

      <Caption>Today's calculated metrics, ready for capture</Caption>
    </Frame>
  </Step>

  <Step title="Automate capture with Workflows + Apps Script">
    Manually copying data every day is laborious and risks missing updates. Instead, leverage Superjoin <b>Workflows</b> and Google Sheets Apps Script to schedule and automate the capture process.

    <Steps>
      <Step title="Open the Workflows menu">
        Click <b>Workflows</b> in Superjoin to get started.

        <Frame>
          <img src="https://usercontent.in.prod.clueso.io/6b101750-ec89-4e66-83bb-0b9079219f65/4bb1a808-c7f1-4860-9974-fe6ac6859e89/88a90d95-1513-47b7-a29b-d19ddf28505a/images/a0599c7b-6cca-4696-8f91-d8e81f68b4fd.png" />

          <Caption>Superjoin sidebar showing the Workflows option</Caption>
        </Frame>
      </Step>

      <Step title="Create a new workflow">
        Click <b>Create New Workflow</b> and name it "Day on Day Trends" for easy identification.

        <Frame>
          <img src="https://usercontent.in.prod.clueso.io/6b101750-ec89-4e66-83bb-0b9079219f65/4bb1a808-c7f1-4860-9974-fe6ac6859e89/88a90d95-1513-47b7-a29b-d19ddf28505a/images/9ed4f01e-3b41-475e-bd50-aceccee297df.png" />

          <Caption>Workflow creation dialog, ready to be named and configured</Caption>
        </Frame>
      </Step>

      <Step title="Add a daily trigger">
        Set a <b>Trigger</b> to run every day at a chosen time (e.g., 9am). This ensures your snapshot is taken before live data changes.

        <Frame>
          <img src="https://usercontent.in.prod.clueso.io/6b101750-ec89-4e66-83bb-0b9079219f65/4bb1a808-c7f1-4860-9974-fe6ac6859e89/88a90d95-1513-47b7-a29b-d19ddf28505a/images/f0fbe47b-bc01-4501-85f3-21114c6042db.png" />

          <Caption>Scheduled trigger set up for daily automation</Caption>
        </Frame>
      </Step>

      <Step title="Add a refresh action">
        After the trigger, add an action to <b>Refresh</b> your connected data source (e.g., the "HubSpot" sheet), ensuring live data and formulas are up-to-date for today’s metrics.

        <Frame>
          <img src="https://usercontent.in.prod.clueso.io/6b101750-ec89-4e66-83bb-0b9079219f65/4bb1a808-c7f1-4860-9974-fe6ac6859e89/88a90d95-1513-47b7-a29b-d19ddf28505a/images/15878f23-694a-4927-b380-bbeab1c95fd0.png" />

          <Caption>Refresh the HubSpot sheet and update live formulas</Caption>
        </Frame>
      </Step>

      <Step title="Run a script to paste values">
        Add a <b>Run Script</b> action to execute a Google Apps Script that copies today’s values (not formulas) from your intermediate formulas sheet into the analysis/trend sheet.
        <Tip>You can use Superjoin AI to generate the Apps Script. Click <b>Test Action</b> to verify.</Tip>
        <Note>It’s critical to paste values only—referencing formulas will result in dynamic updates, not historical snapshots.</Note>

        <Info>Sample Apps Script: copy values from selected rows to the next empty column</Info>

        ```javascript filename="script.gs" Sample Script theme={null}
        /***** ULTRA-SIMPLE SNAPSHOT (values → last column) *****
         * How to use:
         * 1) Extensions → Apps Script → paste this, Save.
         * 2) Click ▶️ Run once (authorize if asked).
         * 3) Run again to append the snapshot.
         ********************************************************/

        /******** SETTINGS (edit these) ********/
        var SOURCE_SHEET_NAME = 'Live Formulas';      // where data lives
        var TARGET_SHEET_NAME = 'Pipeline Analysis';  // where to paste
        var HEADER_CELL_A1    = 'B1';                 // header cell to copy
        var SOURCE_COLUMN     = 2;                    // 2 = column B
        var ROWS_TO_COPY      = [4,5,6,7,8,9,10,13,14,15,16,19,20,21];
        /****************************************/

        function appendSnapshotRun() {
          // If you see "getActive not supported", replace the next line with:
          // var ss = SpreadsheetApp.openById('PUT_SPREADSHEET_ID_HERE');
          var ss = SpreadsheetApp.getActiveSpreadsheet();

          var src = ss.getSheetByName(SOURCE_SHEET_NAME);
          var dst = ss.getSheetByName(TARGET_SHEET_NAME);
          if (!src) throw new Error('Missing source sheet: ' + SOURCE_SHEET_NAME);
          if (!dst) throw new Error('Missing target sheet: ' + TARGET_SHEET_NAME);

          // Next empty column on target
          var destCol = dst.getLastColumn() + 1;
          if (destCol < 1) destCol = 1;

          // Header (value only)
          var headerVal = src.getRange(HEADER_CELL_A1).getValue();
          dst.getRange(1, destCol).setValue(headerVal);

          // Read needed values from the source column in one go
          var maxRow = _maxRow(ROWS_TO_COPY);
          var colVals = src.getRange(1, SOURCE_COLUMN, maxRow, 1).getValues(); // 2D

          // Paste values into the last column at chosen rows
          for (var i = 0; i < ROWS_TO_COPY.length; i++) {
            var r = ROWS_TO_COPY[i];
            if (r > 0) {
              var v = colVals[r - 1][0];
              dst.getRange(r, destCol).setValue(v);
            }
          }

          Logger.log('Done! Snapshot pasted into column ' + destCol + ' of "' + TARGET_SHEET_NAME + '".');
        }

        /* Helper */
        function _maxRow(arr) {
          var m = 0;
          for (var i = 0; i < arr.length; i++) if (+arr[i] > m) m = +arr[i];
          return m;
        }
        ```

        <Frame>
          <img src="https://usercontent.in.prod.clueso.io/6b101750-ec89-4e66-83bb-0b9079219f65/4bb1a808-c7f1-4860-9974-fe6ac6859e89/88a90d95-1513-47b7-a29b-d19ddf28505a/images/457e8794-a41f-455c-b8e1-e7500aa3832b.png" />

          <Caption>Resulting analysis sheet after the script—values are pasted, not formulas</Caption>
        </Frame>
      </Step>

      <Step title="Save the action and workflow">
        Click <b>Save Action</b> and then <b>Save Workflow</b> to finalize your automation. Your routine will now run daily, refreshing data and archiving each snapshot for seamless trend analysis.

        <Frame>
          <img src="https://usercontent.in.prod.clueso.io/6b101750-ec89-4e66-83bb-0b9079219f65/4bb1a808-c7f1-4860-9974-fe6ac6859e89/88a90d95-1513-47b7-a29b-d19ddf28505a/images/f7d73f81-8a65-44e2-8b48-93a81c37c128.png" />

          <Caption>Workflow successful and ready for daily execution</Caption>
        </Frame>
      </Step>
    </Steps>
  </Step>
</Steps>

***

## What’s next?

You now have an automated day-over-day trend system in Google Sheets powered by Superjoin. Every morning, your trend sheet will be updated automatically with the latest metrics, letting you analyze historical trends without manual work.

* Set up email reports using Scheduled Reports
* Extend your workflow to capture other key metrics
* Visualize your trends with chart recommendations
