# Summing a value across all my devices while keeping the \_time column.

**URL:** <https://community.influxdata.com/t/summing-a-value-across-all-my-devices-while-keeping-the-time-column/57022>\
**Category:** InfluxDB 2\
**Tags:** influxdb, grafana, flux\
**Created:** [April 15, 2025, 4:42pm UTC](https://community.influxdata.com/t/summing-a-value-across-all-my-devices-while-keeping-the-time-column/57022 "2025-04-15T16:42:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Celeste](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/celeste/32/17011_2.png) [@Celeste](https://community.influxdata.com/u/Celeste)\
**Post date:** [April 15, 2025, 4:42pm UTC](https://community.influxdata.com/t/summing-a-value-across-all-my-devices-while-keeping-the-time-column/57022/1 "2025-04-15T16:42:57Z")

</div>

Hi, I am plotting on Grafana using flux.  
I am having trouble summing a value across all my devices while keeping the \_time column.

For example, below is my working code for displaying battery state of charge. This displays all the devices in a separate lines. I would like to sum them. For example, if I have three devices and one is at 30%, one is at 80% and another at 100% the plot would read 210.

The problem is that when I use sum() it eliminates my \_time column.  
I attached a csv.

Thank you.

Code:  
collectionInterval = 5.0

from(bucket: “Bytes”)  
|\> range(start: v.timeRangeStart, stop: v.timeRangeStop)  
|\> filter(fn: (r) =\> r.\_measurement == “battery”)  
|\> filter(fn: (r) =\> r.\_field == “bms\_soc”)  
|\> aggregateWindow(every: duration(v:(uint(v: v.timeRangeStop) - uint(v: v.timeRangeStart))/uint(v: 800)), fn:mean)  
|\> pivot(rowKey:[“\_time”], columnKey: [“\_field”], valueColumn: “\_value”)

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [April 15, 2025, 5:51pm UTC](https://community.influxdata.com/t/summing-a-value-across-all-my-devices-while-keeping-the-time-column/57022/2 "2025-04-15T17:51:23Z")

</div>

Hello @Celeste,  
Yes this makes sense because there is one \_time value per \_value. If you sum them there isn’t an obvious choice for which time value should be retained. What do you imagine the ouptut would look like?

I don’t see a CSV can you please attach it again?

I would also try using findrecord() function [findRecord() function | Flux Documentation](https://docs.influxdata.com/flux/v0/stdlib/universe/findrecord/)  
and retaining a time stamp value of your choice and then creating a new column with that value with:  
map() [map() function | Flux Documentation](https://docs.influxdata.com/flux/v0/stdlib/universe/map/#Copyright)

---

<div class="post-metadata">

**Author:** ![Celeste](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/celeste/32/17011_2.png) [@Celeste](https://community.influxdata.com/u/Celeste)\
**Post date:** [April 24, 2025, 8:26pm UTC](https://community.influxdata.com/t/summing-a-value-across-all-my-devices-while-keeping-the-time-column/57022/3 "2025-04-24T20:26:17Z")

</div>

Hi, thank you Anais. I submitted this in February and Influx put my account on hold. It took Influx two months to post this to the forum. I found a different solution but I will keep findRecord() in mind.

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [April 28, 2025, 6:50pm UTC](https://community.influxdata.com/t/summing-a-value-across-all-my-devices-while-keeping-the-time-column/57022/4 "2025-04-28T18:50:27Z")

</div>

hello @Celeste,  
That’s strange. On the forums it shows that you wrote this question  
13d ago not in feburary. Why was it put on hold?

---

<div class="post-metadata">

**Author:** ![Celeste](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/celeste/32/17011_2.png) [@Celeste](https://community.influxdata.com/u/Celeste)\
**Post date:** [April 29, 2025, 3:03am UTC](https://community.influxdata.com/t/summing-a-value-across-all-my-devices-while-keeping-the-time-column/57022/5 "2025-04-29T03:03:41Z")

</div>

I am not sure. I submitted this February and could’t post it. I just got this message below. Then 13 days ago my account was no longer on hold and it was posted. Over a month is kind of a long time to put a user on hold for no reason. Perhaps you could bring this up with your team?  
Thank you again!

> Hello,
> 
> This is an automated message from InfluxData Community Forums to let you know that your account has been temporarily placed on hold as a precautionary measure.
> 
> Please do continue to browse, but you won’t be able to reply or create topics until a [staff member](https://community.influxdata.com/about) reviews your most recent posts. We apologize for the inconvenience.
> 
> For additional guidance, refer to our [community guidelines](https://community.influxdata.com/guidelines).

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [April 29, 2025, 7:00pm UTC](https://community.influxdata.com/t/summing-a-value-across-all-my-devices-while-keeping-the-time-column/57022/6 "2025-04-29T19:00:05Z")

</div>

@Celeste ahhh Its possible you tried to ask a question on the one day when we temporarily disabled commenting to deal with some spam attacks. I’m so sorry about that!

---

<div class="post-metadata">

**Author:** ![Celeste](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/celeste/32/17011_2.png) [@Celeste](https://community.influxdata.com/u/Celeste)\
**Post date:** [April 29, 2025, 7:46pm UTC](https://community.influxdata.com/t/summing-a-value-across-all-my-devices-while-keeping-the-time-column/57022/7 "2025-04-29T19:46:41Z")

</div>

Oh, ok! Got it thank you.
