# Conditional counting in kibana

**URL:** <https://discuss.elastic.co/t/conditional-counting-in-kibana/87200>\
**Category:** Kibana\
**Created:** [May 26, 2017, 3:43am UTC](https://discuss.elastic.co/t/conditional-counting-in-kibana/87200 "2017-05-26T03:43:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sureshboiina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sureshboiina/32/79183_2.png) [@sureshboiina](https://discuss.elastic.co/u/sureshboiina)\
**Post date:** [May 26, 2017, 3:43am UTC](https://discuss.elastic.co/t/conditional-counting-in-kibana/87200/1 "2017-05-26T03:43:51Z")

</div>

Hello

we early use qlikview to do some aggregations like

Count(Distinct IF((Tier = 'Tier 1' AND AGGR(Count({$\<Week= week1\>}SiteID), ClusterCode, Week) \>= 6) OR (Tier = 'Tier 2' AND AGGR(Count({$\<Week= week1\>}SiteID), ClusterCode, Week) \>= 5) )

something like field tier=tier 1 and get the count by clustercode,week and it should be \>= 6 then only count

But we want achieve same thing in **Kibana** , Actually we tried using Timeline but not able to figure it out  
Please help us on this

Thanks,

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [May 26, 2017, 5:57pm UTC](https://discuss.elastic.co/t/conditional-counting-in-kibana/87200/2 "2017-05-26T17:57:30Z")

</div>

I'm not following along with your question very well. Maybe you could post a sample of a simple set of data to illustrate your question?

Is your issue about grouping data by specific weekly buckets? Do you already have a `week` field in your data? Or is that what you're trying to solve?

I also don't understand the `>=6`. Is 6 the week number or the count of something?

Regards,  
Lee

---

<div class="post-metadata">

**Author:** ![sureshboiina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sureshboiina/32/79183_2.png) [@sureshboiina](https://discuss.elastic.co/u/sureshboiina)\
**Post date:** [May 27, 2017, 1:33am UTC](https://discuss.elastic.co/t/conditional-counting-in-kibana/87200/3 "2017-05-27T01:33:53Z")

</div>

ok, in words get the weekly count whose (Tier value in 'Tier1' and group by clustercode whose count should be \>=6)

means(for this week how many clustercode falls in tier1 should be \>=6 than only count that as one document) and so on we need to add 3 different conditions with logical OR and get the distinct count.

X-axis=weekly  
y-axis=counts based on above condition

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:** [June 24, 2017, 1:35am UTC](https://discuss.elastic.co/t/conditional-counting-in-kibana/87200/4 "2017-06-24T01:35:07Z")

</div>

Closed on June 24, 2017, 1:35am UTC

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