# Combining cardinality and sum metrics in timelion

**URL:** <https://discuss.elastic.co/t/combining-cardinality-and-sum-metrics-in-timelion/201287>\
**Category:** Kibana\
**Tags:** timelion\
**Created:** [September 26, 2019, 5:39pm UTC](https://discuss.elastic.co/t/combining-cardinality-and-sum-metrics-in-timelion/201287 "2019-09-26T17:39:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![apiras](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@apiras](https://discuss.elastic.co/u/apiras)\
**Post date:** [September 26, 2019, 5:39pm UTC](https://discuss.elastic.co/t/combining-cardinality-and-sum-metrics-in-timelion/201287/1 "2019-09-26T17:39:30Z")

</div>

Hi all,  
I don't find a good combination of commands to create a timelion visualization to show the sum of the age of unique users.

My idea was to select users by cardinality metric on 'userId' field and sum the age of resulting users by sum metric on 'age' field.

Some on my wrong tests with timelion expressions:

`.es(index='*-users-*', timefield=ts, metric=cardinality:userId).es(index='*-users-*', timefield=ts, metric=sum:age).lines(width=2, stack=false, steps=true).color(red).label('Age')`  
[timelion\_vis] \> Error: in cell #1: [parsing\_exception] [query\_string] unknown token [START\_OBJECT] after [query], with { line=1 & col=338 }

`.es(index='*-users-*', timefield=ts, metric=cardinality:userId, metric=sum:age).lines(width=2, stack=false, steps=true).color(red).label('Age')`  
I got 1 distinct line for each metric.

Any idea or advice is welcomed.  
Thanks

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 27, 2019, 2:35pm UTC](https://discuss.elastic.co/t/combining-cardinality-and-sum-metrics-in-timelion/201287/2 "2019-09-27T14:35:14Z")

</div>

Have you tried using `split` instead of `metric=cardinality`?

 ![26%20AM](https://us1.discourse-cdn.com/elastic/original/3X/7/c/7cbf26d23f2ef40cf62a9b903c709d1603d10a51.jpeg)

---

<div class="post-metadata">

**Author:** ![apiras](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@apiras](https://discuss.elastic.co/u/apiras)\
**Post date:** [October 2, 2019, 6:51am UTC](https://discuss.elastic.co/t/combining-cardinality-and-sum-metrics-in-timelion/201287/3 "2019-10-02T06:51:38Z")

</div>

No yet, I'll try. Thanks @Nathan_Reese

---

<div class="post-metadata">

**Author:** ![apiras](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@apiras](https://discuss.elastic.co/u/apiras)\
**Post date:** [October 4, 2019, 1:08pm UTC](https://discuss.elastic.co/t/combining-cardinality-and-sum-metrics-in-timelion/201287/4 "2019-10-04T13:08:11Z")

</div>

Sorry, the split does not help.  
By using it, I have 1 line for each keyword involved in the split. In fact, in your images there are 5 lines.

I'd like to have only the line of the sum of the values for distinct users.

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [October 4, 2019, 1:47pm UTC](https://discuss.elastic.co/t/combining-cardinality-and-sum-metrics-in-timelion/201287/5 "2019-10-04T13:47:32Z")

</div>

I am not sure this is possible. You can create a feature request at [https://github.com/elastic/kibana/issues/new?template=Feature\_request.md](https://github.com/elastic/kibana/issues/new?template=Feature_request.md). Be sure to include a detailed description of your use case along with a sample data set and expected out come

---

<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 1, 2019, 1:47pm UTC](https://discuss.elastic.co/t/combining-cardinality-and-sum-metrics-in-timelion/201287/6 "2019-11-01T13:47:46Z")

</div>

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