--- id: time-compare title: Time Compare slug: /help/docs/search/time-compare/ canonical: https://www.sumologic.com/help/docs/search/time-compare/ --- import useBaseUrl from '@docusaurus/useBaseUrl'; ## Time Compare Button The **Time Compare** button becomes available in the **Aggregates** tab when you run an aggregate search, and allows you to run a compare operation automatically from your search results. The Time Compare button uses the [`compare`](#compare-operator) operator automatically in a query with a click. The `compare` operator allows you to compare current search results with data from a past time period for aggregate searches. Compare can only be used in aggregate searches that use operators like `avg`, `count`, `pct`, or `sum`. For more information, see [Group or Aggregate Operators](/docs/search/search-query-language/group-aggregate-operators). You can use Time Compare to: * Evaluate the performance metrics of a website, such as the latency or the number of exceptions, before and after a deployment.   * Track the root cause of a production issue quickly by tracking specific keywords, such as memory exceptions, and comparing them with historic data to find any anomalous trends. * Compare the daily active or weekly active users on your website for strategic business insights. * Identify malicious activity or attacks by comparing failed login attempts against past averages. Use the compare operator in the following ways: * Compare with a single time period in the past. * Compare with multiple time periods in the past. * Compare with an aggregate over multiple time periods in the past. By default, results are displayed in the **Aggregates** tab on the search page in a table. Each column of the output table contains results from one of the specified queries. The first column is the field being grouped by which contains results from the present time (or the time range specified in the time range field). Additional columns are suffixed by the timeshift (the period shifted back in time) of the queries. From here, you can select a chart type to display results visually. For example, if you were doing a comparison with yesterday, when you use the compare operator after the count operator, the aggregation table results will display the column names `_count` and `_count_1d`. You can also customize the prefix for a query by specifying an alias. See the [Advanced](#advanced) section for details. ### Default Time Compare Click the **Time Compare** button to run the default timeshift comparison of 1 day. Or select another timeshift comparison from the menu. Time Compare button The comparison results appear in a new column titled with the timeshift. Time compare results ### Custom Time Compare To create a custom Time Compare, select **Custom** from the menu, then make your selections in the Custom Time Compare query builder dialog. You can retrieve time-shifted data up to the last 40 days. We do not support going back further in time. Customtimecompare 1. Compare this query to a `[number] [hour, day, week]` historical timeshift. 1. With `[number]` time period(s). If the number is bigger than 0: 1. Using `[Individual, Average, Min, or Max]` historical results. * Individual - displays each time comparison separately, for example, on a different line. * Average - takes the average of your historical comparisons. * Min - takes the minimum of your historical comparisons. * Max - takes the maximum of your historical comparisons. 1. Click **Run**. For example, if you wanted to compare the behavior of backfill errors on continuous queries over the last seven days, use the following query: ```sumo backfill error | timeslice by 1m | count _timeslice ``` :::note Do not alias `timeslice`, as we will use the `compare` operator. ::: Then, from the **Time Compare** button, select **Custom**, and set the **Custom Time Compare** dialog settings to: Custom Time Compare dialog settings From the results in the **Aggregates** tab, you can select the line chart icon, and display your results as: Compare example For more compare operator examples, see [Examples](./time-compare.md). ## Compare vs. LogCompare The [`compare`](/docs/search/search-query-language/search-operators/compare) and [`logcompare`](/docs/search/behavior-insights/logcompare) operators are very similar in syntax and functionality, but they handle different types of data: * `compare` is used for aggregated numeric data (such as: for analyzing results from a [group by](/docs/search/search-query-language/group-aggregate-operators) query or a query with aggregation operators such as count, sum, and avg). * `logcompare` is used for log signature counts (used right after the first pipe). ## Compare Operator The `compare` operator allows you to compare current search results with data from a past time period for aggregate searches. Compare can only be used in aggregate searches that use operators like avg, count, pct, or sum. For complete details, refer to [Group](/docs/search/search-query-language/group-aggregate-operators). It will also work with `outlier`, `timeslice`, and `transpose`. If you want to use compare with timeslice, do not alias timeslice. ### Syntax #### Single Comparison Compare the present results with a single time period in the past. To make the comparison, specify the time interval you want to go back, in the form of number and time granularity: ```sumo ... | compare timeshift