# How to compare for values in previous records

**URL:** <https://discuss.elastic.co/t/how-to-compare-for-values-in-previous-records/91131>\
**Category:** Logstash\
**Created:** [June 28, 2017, 2:52pm UTC](https://discuss.elastic.co/t/how-to-compare-for-values-in-previous-records/91131 "2017-06-28T14:52:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tejas\_Ghutukade](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Tejas\_Ghutukade](https://discuss.elastic.co/u/Tejas_Ghutukade)\
**Post date:** [June 28, 2017, 2:52pm UTC](https://discuss.elastic.co/t/how-to-compare-for-values-in-previous-records/91131/1 "2017-06-28T14:52:41Z")

</div>

Hi,

i'am trying to read a csv file with log data that is arranged according to timestamp.  
i want to check the current record value with all the previous records values and if the condition is true set a field with value 1 or else 0.  
currently m able to check with the immediate previous record but i want to check with all the previous records.  
Is it possible to do that in aggregate filter.  
my current aggregate filter is as follows

```
aggregate {
	task_id => "%{odr}"
	code => "
		map['dur'] ||= event.get('endtime');
		event.set('cc', (event.get('starttime') < map['dur'])?1:0);
		map['dur'] = event.get('endtime');
	"
	push_previous_map_as_event => true
	push_map_as_event_on_timeout => true
	timeout_task_id_field => "odr"
	timeout => 30
	timeout_tags => ['_aggregatetimeout']
	timeout_code => ""
}

```

Thanks

---

<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:** [July 26, 2017, 2:52pm UTC](https://discuss.elastic.co/t/how-to-compare-for-values-in-previous-records/91131/2 "2017-07-26T14:52:57Z")

</div>

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