---
schema_version: "1"
id: 34503fe2e8973b9f973d2751e431e06151100359d6c5b92621b9410465447499
title: Define Relative Time-Window Metrics
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/data/264-0-0/c360_a_insight_relative_time_metrics.md
canonical_url: https://help.salesforce.com/s/articleView?id=data.c360_a_insight_relative_time_metrics.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 1751682758a49e5ac2b3a363c60f74c601d8c8bfe036a8230e34939a4a0a2006
description: Get real-time Data Cloud insights with metrics based on rolling time windows. Determine metrics using relative timeframes, such as a specified number of past seconds, minutes, or days.
products:
  - Data 360
release: "264"
---
# Define Relative Time-Window Metrics

Get real-time Data Cloud insights with metrics based on rolling time windows. Determine metrics using relative timeframes, such as a specified number of past seconds, minutes, or days.

## Calculated Insights Time-Window Metrics

For calculated insights, use the `NOW` function to establish dynamic or relative time windows. The `SECOND_ADD` and `SECOND_SUB` functions provide more precise control to define the exact time window for your metrics.

- **Availability:**
    - The `NOW`, `SECOND_ADD`, and `SECOND_SUB` functions are available in the transform node for [Visual Insight Builder](https://help.salesforce.com/s/articleView?id=data.c360_a_working_with_nodes_in_builder.htm&release=264.0.0&type=5 "Visual Insight Builder uses a low-code, drag-and-drop interface to simplify the creation of streaming, calculated, and real-time insights. Visual components replace complex code, allowing you to develop metrics and expressions, regardless of technical expertise.").
    - These functions are included in the [SQL Functions for Insights](https://help.salesforce.com/s/articleView?id=data.c360_a_calculated_insights_aggregates.htm&release=264.0.0&type=5 "Use these aggregate, datetime, analytical, formatting, math and statistical, and boolean functions when you author calculated insights in Data 360. The Aggregatable column indicates whether a function's output can be rolled up across fewer dimensions when queried in segments or activations.").
- **Filtering:** You can define a relative time filter with the Visual Builder filter node "Relative DateTime operator" option.
- **Flexibility:** You can define and calculate dynamic metrics over configurable time intervals, from seconds to years (365+ days).

## Real-Time Time-Window Metrics

Use dynamic time-window metrics for real-time calculation of metrics over specific time frames. Use these metrics for personalized product recommendations informed by recent activity. For instance, you can:

- Count website interactions for the last 10 minutes to recommend products similar to recent views.
- Remove products that weren’t viewed in the last 10 minutes.

## How Real-Time Insights Update Metrics

Real-time insights update metrics when a data event is processed.

- Calculation at query time: The value for this metric is calculated at graph query time.
- Handling no events: When no events are processed, the metric value is calculated based on the defined relative time window. For example, if your metric is "count of product clicks for the last ten minutes," and no clicks occur during this time, the metric is 0.
- Client-side processing: Real-time graph clients must process the real-time insight data from the client side to get the true metric at graph query time.

## Streamlining Data Aggregation with Submetrics and Time Buckets

To streamline data aggregation and minimize storage within the real-time graph, the time-window process employs submetrics and time buckets within the user-defined time interval. This process eliminates the need to store every event in the real-time graph.

- **How it works:** When processing a real-time event, the `NOW` function compares the event time of each event within a 5-minute sub-time window to determine the appropriate window size. The function applies five different window types in a hierarchical order, with each type covering a specific time range relative to the compute time.
- **Automatic dimension creation:** When a dynamic time window is defined, the function creates the dimensions `window_start__c` and `window_end__c` as real-time insight dimensions.
- **Improved storage cost:** The time window process can result in an approximate metric rather than an exact count of events. The process is optimized to store the most recent data in smaller, precise buckets, grouping older data into larger buckets, to balance accuracy with storage cost.

**Window Types and Logic:**

- Five-Minute Windows (Most Recent Data)
    - Covers: Last 1 hour from compute time
    - Maximum Buckets: 12 (ensures at least 1 hour of coverage)
- One-Hour Windows (Recent Data)
    - Covers: From 1 hour ago to 1 day ago
    - Maximum Buckets: 23
- Daily Windows (Medium-Term Historical Data)
    - Covers: From 1 day ago to 1 month ago
    - Bucket Examples: \[2025-03-19 00:00 - 23:59\], \[2025-03-20 00:00 - 23:59\]
    - Maximum Buckets: ~30 (varies by length of month)
- Monthly Windows (Long-Term Historical Data)
    - Covers: From 1 month ago to 1 year ago
    - Bucket Examples: \[2025-02-01 00:00 - 2025-02-28 23:59\], \[2025-03-01 00:00 - 2025-03-31 23:59\]
    - Maximum Buckets: 11
- Yearly Windows (Oldest Data)
    - Covers: All data older than 1 year from compute time
    - Bucket Examples: \[2024-01-01 00:00 - 2024-12-31 23:59\], \[2023-01-01 00:00 - 2023-12-31 23:59\]
    - Maximum Buckets: Unlimited (depends on data age)

**Example: Processing 25 Months of Minute-Level Data**

- Dataset: Records every minute from April 1, 2023, to May 1, 2025
- Compute Time: May 1, 2025, 10:30 AM
- Total Records: ~1,081,440 records

   
| Window Type | Time Range | DMO Event Count | Real Time Graph Aggregate Count |
| --- | --- | --- | --- |
| 5-minute | May 1, 2025 09:30-10:30 | 60 records | 12 records |
| 1-hour | April 30, 2025 10:30 to May 1, 2025 09:30 | 1380 records | 23 records |
| Daily | March 31 to April 30, 2025 | 44,640 records | 31 records |
| Monthly | May 1, 2024 to March 31, 2025 | 525,600 records | 11 records |
| Yearly | April 1, 2023 May 1, 2024 | 525,600 records | 2 records |

#### See Also

- [_Salesforce Help_: Supported SQL Statements for Insights](https://help.salesforce.com/s/articleView?id=data.c360_a_calculated_insights_aggregates.htm&release=264.0.0&type=5 "Use these aggregate, datetime, analytical, formatting, math and statistical, and boolean functions when you author calculated insights in Data 360. The Aggregatable column indicates whether a function's output can be rolled up across fewer dimensions when queried in segments or activations.")
- [_Salesforce Help_: Create a Calculated Insight Using SQL](https://help.salesforce.com/s/articleView?id=data.c360_a_get_started_with_calculated_insights.htm&release=264.0.0&type=5 "Write SQL expressions to create your metrics and dimensions from mapped objects and fields. You can create a calculated insight in Data 360 using SQL.")
- [_Salesforce Help_: Create a Calculated Insight Using Builder](https://help.salesforce.com/s/articleView?id=data.c360_a_create_a_calculated_insight_using_builder.htm&release=264.0.0&type=5 "Create a calculated insight without using SQL by using the builder tool in Data 360.")
- [_Salesforce Help_: Create a Real-Time Insight Using Builder](https://help.salesforce.com/s/articleView?id=data.c360_a_create_real_time_insight.htm&release=264.0.0&type=5 "You can create real-time insights with a real-time data graph and related data model objects (DMOs). A related DMO is a DMO not defined in the real-time data graph but can be used as a real-time dimension.")