# Pipeline aggregation | Cumulative sum aggregation on a nested field

**URL:** <https://discuss.elastic.co/t/pipeline-aggregation-cumulative-sum-aggregation-on-a-nested-field/307539>\
**Category:** Elasticsearch\
**Created:** [June 17, 2022, 7:13pm UTC](https://discuss.elastic.co/t/pipeline-aggregation-cumulative-sum-aggregation-on-a-nested-field/307539 "2022-06-17T19:13:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mehtaanshul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mehtaanshul/32/95596_2.png) [@mehtaanshul](https://discuss.elastic.co/u/mehtaanshul)\
**Post date:** [June 17, 2022, 7:13pm UTC](https://discuss.elastic.co/t/pipeline-aggregation-cumulative-sum-aggregation-on-a-nested-field/307539/1 "2022-06-17T19:13:08Z")

</div>

My Elasticsearch index mappings -

```auto
{
    "mappings": {
        "properties": {
            "timestamp": {
                "type": "date"
            },
            "detail": {
                "type": "nested",
                "properties": {
                    "attributes": {
                        "properties": {
                            "levelValue": {
                                "type": "text",
                                "fields": {
                                    "keyword": {
                                        "type": "keyword",
                                        "ignore_above": 256
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

```

Possible values of levelValue -\> A, B, C

A new document is created in my index whenever levelValue changes it's value

I want to create a time series graph which will show the levelValue of objects over time and I am trying to use cumulative sum query to achieve this.  
and **I cannot change my index mappings**.

**Query**

```auto
{
        "size": 0,
        "aggs": {
            "updates_over_time": {
                "date_histogram": {
                    "field": "timestamp",
                    "calendar_interval": "day"
                }
            },
            "detail": {
                "nested": {
                    "path": "detail"
                },
                "aggs": {
                    "levelValue_updates": {
                        "terms": {
                            "field": "detail.attributes.levelValue.keyword"
                        }
                    },
                    "cumulative_levelValue_updates": {
                        "cumulative_sum": {
                            "buckets_path": "levelValue_updates"
                        }
                    }
                }
            }
        }
    }

```

I am getting the following error -

```auto
\"reason\":\"Validation Failed: 1: cumulative_sum aggregation [cumulative_levelValue_updates] must have a histogram, date_histogram or auto_date_histogram as parent;\"

```

---

<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 15, 2022, 7:14pm UTC](https://discuss.elastic.co/t/pipeline-aggregation-cumulative-sum-aggregation-on-a-nested-field/307539/2 "2022-07-15T19:14:02Z")

</div>

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