# Display the consumed energy for every single device in a Trend

**URL:** <https://discuss.elastic.co/t/display-the-consumed-energy-for-every-single-device-in-a-trend/337186>\
**Category:** Kibana\
**Tags:** lens, visualisation\
**Created:** [June 29, 2023, 11:41am UTC](https://discuss.elastic.co/t/display-the-consumed-energy-for-every-single-device-in-a-trend/337186 "2023-06-29T11:41:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![deepack86](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@deepack86](https://discuss.elastic.co/u/deepack86)\
**Post date:** [June 29, 2023, 11:41am UTC](https://discuss.elastic.co/t/display-the-consumed-energy-for-every-single-device-in-a-trend/337186/1 "2023-06-29T11:41:03Z")

</div>

Hi together,

i have a site with three electric devices but only one energy meter.  
The task is to display the consumed energy for every single device in a Trend.  
So i get the actual consumed accumulated Energy from the energymeter  
There is only one device at time in operation and i have for every device a operational message.

I have tried to solve the task with lens visualization. In my mind i need some variables to  
solve the problem.  
If the device 1 is in operation, lets save the actual accumulated energy and wait if the device  
is not more in operation and subtract the first saved value from the present accumulated energy.  
The result should be saved in a variable, but how ? 🙃

here is my code:

```auto
ifelse( last_value(value.value_float32,kql='sensor.name.keyword : "air_01_compressor_03_working_b" ') == 1, 0, last_value(value.value_float32, kql='sensor.name.keyword : air_01_kompressor_03_energy-sum_m and value.value_float32 : * ') - last_value(value.value_float32, kql='sensor.name.keyword : air_01_kompressor_03_energy-sum_m and value.value_float32 : * ', shift='"1d'))

```

Elastic Version: 8.6.1

Maybe someone have an idea or tip how to solve it ? 😃

Greetz

Thomas

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [July 25, 2023, 8:08am UTC](https://discuss.elastic.co/t/display-the-consumed-energy-for-every-single-device-in-a-trend/337186/2 "2023-07-25T08:08:25Z")

</div>

Sorry for the late reply, have you already solved your issue?

---

<div class="post-metadata">

**Author:** ![deepack86](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@deepack86](https://discuss.elastic.co/u/deepack86)\
**Post date:** [August 17, 2023, 11:59am UTC](https://discuss.elastic.co/t/display-the-consumed-energy-for-every-single-device-in-a-trend/337186/3 "2023-08-17T11:59:25Z")

</div>

No Problem. Jep, i have already the problem

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 14, 2023, 11:59am UTC](https://discuss.elastic.co/t/display-the-consumed-energy-for-every-single-device-in-a-trend/337186/4 "2023-09-14T11:59:36Z")

</div>

Closed on September 14, 2023, 11:59am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
