# Canvas dropdown filter

**URL:** <https://discuss.elastic.co/t/canvas-dropdown-filter/185006>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [June 10, 2019, 2:40pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006 "2019-06-10T14:40:03Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![wadhah](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wadhah](https://discuss.elastic.co/u/wadhah)\
**Post date:** [June 10, 2019, 2:40pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/1 "2019-06-10T14:40:03Z")

</div>

Hello,  
how can I exploit the "dropdown column" : for example i am showing a metric (costs), and I want to display the "costs" of different "categories".  
When it's on 'any' it gives me a correct value which is the sum of the costs of different categories.  
However, when I choose one of the "categories" , It is all the time giving me 0.  
So, can you tell me please how can I proceed?

---

<div class="post-metadata">

**Author:** ![tims](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tims/32/46750_2.png) [@tims](https://discuss.elastic.co/u/tims)\
**Post date:** [June 14, 2019, 3:33pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/2 "2019-06-14T15:33:11Z")

</div>

Hi wadhah, it sounds like something is mismatched between the value and filter columns you are deriving for the dropdown column. Could you copy/paste the expression you are generating?

---

<div class="post-metadata">

**Author:** ![wadhah](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wadhah](https://discuss.elastic.co/u/wadhah)\
**Post date:** [June 16, 2019, 2:37pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/3 "2019-06-16T14:37:12Z")

</div>

Hello @tims,  
Thank you for the update.  
Here's my metric's expression:  
filters  
| essql  
query="SELECT SUM(Costs)  
FROM "azureconsumption\*"  
WHERE MONTH(usageEnd)=MONTH(CURRENT\_DATE)  
"  
| math "SUM\_Costs\_"  
| metric "Euros"  
metricFont={font size=48 family="'Open Sans', Helvetica, Arial, sans-serif" color="#000000" align="center" lHeight=48}  
labelFont={font size=14 family="'Open Sans', Helvetica, Arial, sans-serif" color="#000000" align="center"}  
| render

And Here's the the filter'S expression:  
essql  
query="SELECT ConsumedService  
FROM "azureconsumption\*"  
GROUP BY ConsumedService"  
| dropdownControl valueColumn="ConsumedService" filterColumn="ConsumedService"  
| render

---

<div class="post-metadata">

**Author:** ![tims](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tims/32/46750_2.png) [@tims](https://discuss.elastic.co/u/tims)\
**Post date:** [June 17, 2019, 2:37pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/4 "2019-06-17T14:37:20Z")

</div>

Ok, so I think that you need to update your Costs query to be grouped by ConsumedService so that the value that you are passing in via filterColumn will actually have a corresponding column in the Costs query. If you visualize your Costs query as a datatable you will see that right now it is only returning the total sum not broken out by ConsumedService.

Here is a similar question that was posted a while back that may give you a better idea of some things to try.

> [@Canvas dropdownfilter does not filter](https://discuss.elastic.co/t/canvas-dropdownfilter-does-not-filter/161950):
>
> I'm working on my first Canvas and want to show statistics about my payment brands in my shop, including a time filter and a payment brand filter: Everything works as I want, except for the payment brands filter. After some fiddling, I did get to populate it correctly but when I select one of the payment brands, the chart is not filtered based on that brand (which is my goal) and throws an error (that is gone very quickly, so I had to record my actions to be able to se…

---

<div class="post-metadata">

**Author:** ![wadhah](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wadhah](https://discuss.elastic.co/u/wadhah)\
**Post date:** [June 17, 2019, 8:54pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/5 "2019-06-17T20:54:08Z")

</div>

Hey @tims thank you for your response.  
However I disagree about the fact concerning datatable, because if i pass these sql commands:

SELECT ConsumedService, SUM(Costs)  
FROM "azureconsumption\*"  
WHERE MONTH(usageEnd)=MONTH(CURRENT\_DATE())  
GROUP BY ConsumedService

I get myself a table showing me each ConsumedService and its amount of costs during this month.

---

<div class="post-metadata">

**Author:** ![tims](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tims/32/46750_2.png) [@tims](https://discuss.elastic.co/u/tims)\
**Post date:** [June 17, 2019, 9:02pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/6 "2019-06-17T21:02:06Z")

</div>

so if you use that query, and you name your SUM(Costs) column "sumCosts" or something and then use that column name in the filterColumn, it still returns 0?

---

<div class="post-metadata">

**Author:** ![wadhah](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wadhah](https://discuss.elastic.co/u/wadhah)\
**Post date:** [June 17, 2019, 9:08pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/7 "2019-06-17T21:08:45Z")

</div>

Yes @tims it still returns 0

---

<div class="post-metadata">

**Author:** ![tims](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tims/32/46750_2.png) [@tims](https://discuss.elastic.co/u/tims)\
**Post date:** [June 17, 2019, 9:53pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/8 "2019-06-17T21:53:03Z")

</div>

Hey @wadhah, ok I've attempted to re-create your issue and I think I have using some sample data. It looks like you may be encountering this bug: [https://github.com/elastic/kibana/issues/26497](https://github.com/elastic/kibana/issues/26497)

At this point it sounds like your queries are correct and I could reproduce the dataset coming back as 0 whenever I had categories with spaces or mixed case values, so if your ConsumedService value is a string with either spaces or mixed case then it is filtering incorrectly because of this bug.

---

<div class="post-metadata">

**Author:** ![wadhah](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wadhah](https://discuss.elastic.co/u/wadhah)\
**Post date:** [June 20, 2019, 1:38pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/9 "2019-06-20T13:38:49Z")

</div>

I used an other field where its values are "strings" with only lowercases and still facing the same problem  
@Joe_Fleming

---

<div class="post-metadata">

**Author:** ![wadhah](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wadhah](https://discuss.elastic.co/u/wadhah)\
**Post date:** [June 20, 2019, 3:30pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/10 "2019-06-20T15:30:26Z")

</div>

Hey @tims I found a solution : I used ConsumedService.keyword and it worked, how is that?  
And if you please I have an other question : I have other charts with which I am querying other data from other indexes, is there a way to avoid getting them impacted by the dropdown column? Since whenever I choose one of the categories, i loose these charts (if they are metrics they return 0 .....)

---

<div class="post-metadata">

**Author:** ![tims](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tims/32/46750_2.png) [@tims](https://discuss.elastic.co/u/tims)\
**Post date:** [June 20, 2019, 3:35pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/11 "2019-06-20T15:35:57Z")

</div>

Hi @wadhah, that was going to be my next suggestion. ConsumedService is an analyzed field so if you have values with multiple words it will be broken up when evaluating the filter. Using keyword ensures that it is doing the comparison against the whole string.

Unfortunately, right now the filters are applied to the entire canvas but the ability to apply the filter to specific elements is in the roadmap.

---

<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:** [July 18, 2019, 3:36pm UTC](https://discuss.elastic.co/t/canvas-dropdown-filter/185006/12 "2019-07-18T15:36:04Z")

</div>

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