# Canvas data filtering

**URL:** <https://discuss.elastic.co/t/canvas-data-filtering/165292>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [January 22, 2019, 8:07pm UTC](https://discuss.elastic.co/t/canvas-data-filtering/165292 "2019-01-22T20:07:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomhel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomhel/32/31751_2.png) [@tomhel](https://discuss.elastic.co/u/tomhel)\
**Post date:** [January 22, 2019, 8:07pm UTC](https://discuss.elastic.co/t/canvas-data-filtering/165292/1 "2019-01-22T20:07:36Z")

</div>

My use case for Canvas is all about counting documents and visualizing how many documents that meet different criteria. In almost all cases, I want to count the total number of documents that match some criteria, and show that together wit the count of a further filtering of the total set of matched documents.

Example:

Let's say that I have an index with documents that have the attributes "State" and "ReviewRecord". I want to show in i line chart the total number of documents that match the query "State: Accepted" as well as the number of documents that match the query "State: Accepted AND ReviewRecord: \*", i.e. show the count of accepted documents that have a review record in relation to the total number of accepted documents.

This is easy with filters in regular Kibana visualizations, but I can't figure out a way to do this in Canvas.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [January 22, 2019, 11:41pm UTC](https://discuss.elastic.co/t/canvas-data-filtering/165292/2 "2019-01-22T23:41:30Z")

</div>

There are a couple ways to do this. First you could add a dropdown filter element to the workpad (if you want to be able to change it on the fly). Otherwise in your datasource, depending on what you're using, you can set a query on the data there.

![image](https://us1.discourse-cdn.com/elastic/original/3X/d/9/d940f438d13a08f0014d844b1f8f02c9e2aa8791.png)

---

<div class="post-metadata">

**Author:** ![tomhel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomhel/32/31751_2.png) [@tomhel](https://discuss.elastic.co/u/tomhel)\
**Post date:** [January 23, 2019, 6:21am UTC](https://discuss.elastic.co/t/canvas-data-filtering/165292/3 "2019-01-23T06:21:27Z")

</div>

I can do one query in the datasource, e.g. "State: Accepted", but in my use case I need a second query "State: Accepted AND ReviewRecord: \*". I need to show both in the same chart so that I can display how they relate to each other. In a more generic use case I need N filter queries in the datasource.

As I explained, this is easy with regular Kibana visualizations, but in Canvas I'm limited to one single query.

Or if I go with the filter element on the workpad to filter "State: Accepted", I still need two queries on the datasource: "\*" and "ReviewRecord: \*", so that doesn't work either. I still need to be able to make multiple filters in the datasource.

Think of it as a chart with "Total" and "Filtered":

```
Total: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Filtered: XXXXXXXXXXXXXXXXX
          0 100 200
```

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [January 23, 2019, 9:37pm UTC](https://discuss.elastic.co/t/canvas-data-filtering/165292/5 "2019-01-23T21:37:33Z")

</div>

Have you tried entering this entire query in the datasource query?

`State:Accepted AND ReviewRecord:*`

---

<div class="post-metadata">

**Author:** ![tomhel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomhel/32/31751_2.png) [@tomhel](https://discuss.elastic.co/u/tomhel)\
**Post date:** [January 23, 2019, 9:50pm UTC](https://discuss.elastic.co/t/canvas-data-filtering/165292/6 "2019-01-23T21:50:11Z")

</div>

That query would give me this:

```
Filtered: XXXXXXXXXXXXXXXXX
          0 100 200

```

I also need "Total", i.e. the "State: Accepted" part.

---

<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:** [February 20, 2019, 9:50pm UTC](https://discuss.elastic.co/t/canvas-data-filtering/165292/7 "2019-02-20T21:50:14Z")

</div>

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