diff --git a/docs/user/dashboard/images/lens_time_shift.png b/docs/user/dashboard/images/lens_time_shift.png new file mode 100644 index 000000000000..f7edf80bdd0d Binary files /dev/null and b/docs/user/dashboard/images/lens_time_shift.png differ diff --git a/docs/user/dashboard/lens-advanced.asciidoc b/docs/user/dashboard/lens-advanced.asciidoc index e49db0c0d026..ec8d90aa4920 100644 --- a/docs/user/dashboard/lens-advanced.asciidoc +++ b/docs/user/dashboard/lens-advanced.asciidoc @@ -295,6 +295,41 @@ image::images/lens_advanced_5_2.png[Line chart with cumulative sum of orders mad . Click *Save and return*. +[discrete] +[[compare-time-ranges]] +=== Compare time ranges + +*Lens* allows you to compare the currently selected time range with historical data using the *Time shift* option. + +Time shifts can be used on any metric. The special shift *previous* will show the time window preceding the currently selected one, spanning the same duration. +For example, if *Last 7 days* is selected in the time filter, *previous* will show data from 14 days ago to 7 days ago. + +If multiple time shifts are used in a single chart, a multiple of the date histogram interval should be chosen - otherwise data points might not line up in the chart and empty spots can occur. +For example, if a daily interval is used, shifting one series by *36h*, and another one by *1d*, is not recommended. In this scenario, either reduce the interval to *12h*, or create two separate charts. + +To compare current sales numbers with sales from a week ago, follow these steps: + +. Open *Lens*. + +. From the *Chart Type* dropdown, select *Line*. + +. From the *Available fields* list, drag and drop *Records* to the visualization builder. + +. Copy the *Count of Records* series by dragging it to the empty drop target of the *Vertical axis* dimension group (*Drop a field or click to add*) + +. Shift the second *Count of Records* series by one week to do a week-over-week comparison + +.. Click the new *Count of Records [1]* dimension + +.. Click *Add advanced options* below the field selector + +.. Click *Time shift* + +.. Click the *1 week* option. You can also define custom shifts by typing amount followed by time unit (like *1w* for a one week shift), then hit enter. + +[role="screenshot"] +image::images/lens_time_shift.png[Line chart with week-over-week sales comparison] + [discrete] [[view-customers-over-time-by-continents]] === View table of customers by category over time