# In vega how do I handle "other" cases with a scale

**URL:** <https://discuss.elastic.co/t/in-vega-how-do-i-handle-other-cases-with-a-scale/287363>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [October 21, 2021, 8:22pm UTC](https://discuss.elastic.co/t/in-vega-how-do-i-handle-other-cases-with-a-scale/287363 "2021-10-21T20:22:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsimi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nsimi/32/39013_2.png) [@nsimi](https://discuss.elastic.co/u/nsimi)\
**Post date:** [October 21, 2021, 8:22pm UTC](https://discuss.elastic.co/t/in-vega-how-do-i-handle-other-cases-with-a-scale/287363/1 "2021-10-21T20:22:54Z")

</div>

Hello All,

I have an ordinal scale that contains items [A, B, C] and data that has values of [A,B,C,D,E,F] how do I put D,E, and F under a catch all with the scale? Similar to how "other" functions in other kibana visualizations, I ask because my original data set had too many values for the legend so I am building a second data set that only has a constrained value set so that I can limit my scale to like 10 items and then have others placed under "other"

Thank you!

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [October 27, 2021, 5:40pm UTC](https://discuss.elastic.co/t/in-vega-how-do-i-handle-other-cases-with-a-scale/287363/2 "2021-10-27T17:40:58Z")

</div>

@nyuriks - can u shed some light here.

---

<div class="post-metadata">

**Author:** ![nyuriks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nyuriks/32/26171_2.png) [@nyuriks](https://discuss.elastic.co/u/nyuriks)\
**Post date:** [October 27, 2021, 6:14pm UTC](https://discuss.elastic.co/t/in-vega-how-do-i-handle-other-cases-with-a-scale/287363/3 "2021-10-27T18:14:36Z")

</div>

Hi @nsimi, there is [an example](https://vega.github.io/vega/examples/top-k-plot-with-others/) for `top-K` graph (funny enough it was created after I posted a [similar issue](https://github.com/vega/vega/issues/524) a while back). The main idea is that you want to prepare your data first -- use `aggregate` transformation to group it by some value and sum or count the content of each group. Afterwards, use `window` transformation to sort the result and use `row_number` to decide if you want to keep the value as unique or as part of "all other". A side note -- Elasticsearch can actually do this work for you in many cases, and you can simply look at the resulting data.

---

<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:** [November 24, 2021, 6:14pm UTC](https://discuss.elastic.co/t/in-vega-how-do-i-handle-other-cases-with-a-scale/287363/4 "2021-11-24T18:14:43Z")

</div>

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