# Machine Learning - Default value for buckets with no documents

**URL:** <https://discuss.elastic.co/t/machine-learning-default-value-for-buckets-with-no-documents/289233>\
**Category:** Kibana\
**Tags:** elastic-stack-machine-learning\
**Created:** [November 15, 2021, 8:06pm UTC](https://discuss.elastic.co/t/machine-learning-default-value-for-buckets-with-no-documents/289233 "2021-11-15T20:06:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bpsullivan3](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bpsullivan3](https://discuss.elastic.co/u/bpsullivan3)\
**Post date:** [November 15, 2021, 8:06pm UTC](https://discuss.elastic.co/t/machine-learning-default-value-for-buckets-with-no-documents/289233/1 "2021-11-15T20:06:13Z")

</div>

I am attempting to set up a machine learning job that detects high\_sum of a field for a daily ingest. However, the data I am ingesting is conditional, and we may not actually receive any documents for a given day (most days even). This is a standard result that we would like to capture in this machine learning anomaly detection job. However, my job is not reporting the values I would expect as anomalies. I believe this is because the days without any data are not actually contributing to the detection algorithm.

I have been searching around this forum and elsewhere to no avail looking for a solution to this issue. What I would like to set up is a default value of 0 for those buckets without any documents. How might I go about setting up this job?

Running with ES/Kibana 7.6.0

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [November 15, 2021, 10:22pm UTC](https://discuss.elastic.co/t/machine-learning-default-value-for-buckets-with-no-documents/289233/2 "2021-11-15T22:22:08Z")

</div>

If you are using `sum()` then days without documents will be modeled as `0`.

If you want to ignore (i.e. not model) days without documents, you need to use `non_null_sum()`

See: [Sum functions | Machine Learning in the Elastic Stack [7.15] | Elastic](https://www.elastic.co/guide/en/machine-learning/current/ml-sum-functions.html#ml-nonnull-sum)

---

<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:** [December 13, 2021, 10:22pm UTC](https://discuss.elastic.co/t/machine-learning-default-value-for-buckets-with-no-documents/289233/3 "2021-12-13T22:22:50Z")

</div>

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