# Window Final Result

**URL:** <https://forum.confluent.io/t/window-final-result/4085>\
**Category:** Kafka Streams\
**Created:** [4 February 2022 09:33 UTC](https://forum.confluent.io/t/window-final-result/4085 "2022-02-04T09:33:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hansj.melby](https://avatars.discourse-cdn.com/v4/letter/h/e9c0ed/32.png) [@hansj.melby](https://forum.confluent.io/u/hansj.melby)\
**Post date:** [4 February 2022 09:33 UTC](https://forum.confluent.io/t/window-final-result/4085/1 "2022-02-04T09:33:59Z")

</div>

I am trying to solve an issue maybe best solved with a database, but i wanted to see if it was posible to solve using streaming  
I get power consumption (IOT) readings every 2 second to my kafka topic.  
My goal is to agregate the readings (for each iot device) but i have to agregate for each our.  
E.g all events from 11:00-11:59:59 and then from 12:00 -12:59:59  
I also would like the “result” for the agregation to be stored somewhere (Ktable?)  
is that even posible with streaming?

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [5 February 2022 06:57 UTC](https://forum.confluent.io/t/window-final-result/4085/2 "2022-02-05T06:57:35Z")

</div>

Yes, you can do a windowed aggregation using a tumbling time window.

```nohighlight
KStream input = builder.stream(...);
KTable result = input
    .groupByKey() // or groupBy(...)
    .windowedBy(TimeWindow.ofSizeAndGrace(...))
    .aggregate(...)

```

---

<div class="post-metadata">

**Author:** ![hansj.melby](https://avatars.discourse-cdn.com/v4/letter/h/e9c0ed/32.png) [@hansj.melby](https://forum.confluent.io/u/hansj.melby)\
**Post date:** [7 February 2022 11:36 UTC](https://forum.confluent.io/t/window-final-result/4085/3 "2022-02-07T11:36:32Z")

</div>

Thanks… I will definitly try this out 😃

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [14 February 2022 11:37 UTC](https://forum.confluent.io/t/window-final-result/4085/4 "2022-02-14T11:37:11Z")

</div>

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