Skip to content

Commit d66f810

Browse files
Lens metric trends (elastic#2232)
Closes: elastic#1664 I will create a separate PR for 8.19 once we're good with the content here Find preview page link in one of the comments below.
1 parent f4f60e0 commit d66f810

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
25.5 KB
Loading
27.4 KB
Loading

explore-analyze/visualize/lens.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,54 @@ Color mapping works best with fields that have a reasonable number of distinct v
184184

185185
When choosing colors, consider how they will appear in both light and dark themes. Use theme-aware neutral colors when you want to de-emphasize data.
186186

187+
### Show trends in Metric charts [metric-trends]
188+
```{applies_to}
189+
stack: ga 9.1
190+
serverless: ga
191+
```
192+
193+
When creating **Metric** visualizations with numeric data, you can add trend indicators that compare your primary metric to a secondary value. This feature displays colored badges with directional arrows to help you quickly identify whether values are increasing, decreasing, or staying the same.
194+
195+
| Without trend | With trend |
196+
|--------|-------|
197+
| ![Secondary metric before comparison](../images/secondary_metric_before_compare.png "title =70%") | ![Secondary metric after comparison](../images/secondary_metric_after_compare.png "title =70%") |
198+
199+
To add trend indicators to your metric visualization:
200+
201+
1. Create a **Metric** visualization with a numeric primary metric.
202+
2. Add a secondary metric that represents the comparison value.
203+
204+
::::{tip}
205+
Use the `shift` parameter in formulas to compare current values against historical data. For example, if your primary metric is counting orders (based on an `order_id` field) for the current week, you can use the `count(order_id, shift='1w')` formula to compare this week's count of orders to last week's count.
206+
::::
207+
208+
3. In the secondary metric configuration, look for the **Color by value** option. The possible choices are:
209+
* **None** — No trend indicators (default)
210+
* **Static** — Shows the secondary metric as a badge with a single color that you select
211+
* **Dynamic** — Enables both color coding and directional icons based on the comparison
212+
213+
4. Select **Dynamic** coloring. More options appear.
214+
215+
5. Choose a **Color palette** that matches how you'd like to represent the comparison.
216+
217+
6. Configure the **Display** option:
218+
* **Icon** — Shows only directional arrows: ↑ for increase, ↓ for decrease, = for no change
219+
* **Value** — Shows only the secondary metric value
220+
* **Both** — Shows both the icon and value (default)
221+
222+
7. The secondary metric does not automatically compare with the primary metric. Define the value to **Compare to**:
223+
* **Static value** — Compares against a fixed baseline value that you specify
224+
* **Primary metric** — Compares the secondary metric directly against the primary metric. This option is only available when the primary metric is numeric.
225+
226+
When you select this option, the secondary metric is automatically updated:
227+
228+
* The secondary metric label changes to **Difference**. You can change this by editing the **Prefix** option of the metric.
229+
* If you chose a **Display** option that shows a value, the secondary metric value is automatically updated to show the difference compared to the primary metric.
230+
231+
7. Apply your changes.
232+
233+
The metric visualization is updated and now shows the secondary metric as a comparison with a trend indicator.
234+
187235

188236
### Create visualizations with keyboard navigation [drag-and-drop-keyboard-navigation]
189237

0 commit comments

Comments
 (0)