# Gauge with max count

**URL:** https://discuss.elastic.co/t/gauge-with-max-count/150001
**Category:** Kibana
**Created:** [September 26, 2018, 12:09pm UTC](https://discuss.elastic.co/t/gauge-with-max-count/150001 "2018-09-26T12:09:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![wheelq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wheelq/32/35893_2.png) [@wheelq](https://discuss.elastic.co/u/wheelq)
#### Post date: [September 26, 2018, 12:09pm UTC](https://discuss.elastic.co/t/gauge-with-max-count/150001/1 "2018-09-26T12:09:24Z")

</div>

Please help me to figure out how to create a gauge where:

- max is based on the total unique count of particular field (in my case this is total unique number of logins)
- gauge value is based on total unique count of particular field (in my case this is total unique number of logins) BUT between specified time range (now-4w/w - now)

---

<div class="post-metadata">

### Author: ![jen-huang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jen-huang/32/74327_2.png) [@jen-huang](https://discuss.elastic.co/u/jen-huang)
#### Post date: [September 27, 2018, 2:02am UTC](https://discuss.elastic.co/t/gauge-with-max-count/150001/2 "2018-09-27T02:02:00Z")

</div>

You can do this with the Time Series Visual Builder gauge using a **Bucket Script**.

My example shows the count of the past 6h (Interval setting) as a percentage of the last 7 days (time range filter at the top).

I use the Count aggregation (gives me the total within the last 6h), as well as a Cumulative Sum on the Count aggregation (the total within the last 7 days). Then, I use a Bucket Script to calculate the percentage.

Lastly, I format the value as Percentage in the Data Options.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/6/86816644251a5292c6b0ab739ac05fd9d40ae344.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/c/4c348758cacce885afb585a88451416570b0ec9a.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/a/da4d78888f2585b34cae26bee5c563bf65f7f360.png)

---

<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: [October 25, 2018, 2:02am UTC](https://discuss.elastic.co/t/gauge-with-max-count/150001/3 "2018-10-25T02:02:01Z")

</div>

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