# Canvas : is it possible to send varaibles to esql, edocs query argument or is it a limitation in canvas

**URL:** <https://discuss.elastic.co/t/canvas-is-it-possible-to-send-varaibles-to-esql-edocs-query-argument-or-is-it-a-limitation-in-canvas/181524>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [May 17, 2019, 7:03am UTC](https://discuss.elastic.co/t/canvas-is-it-possible-to-send-varaibles-to-esql-edocs-query-argument-or-is-it-a-limitation-in-canvas/181524 "2019-05-17T07:03:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TEJASWI\_CHUNDURI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tejaswi_chunduri/32/46271_2.png) [@TEJASWI\_CHUNDURI](https://discuss.elastic.co/u/TEJASWI_CHUNDURI)\
**Post date:** [May 17, 2019, 7:03am UTC](https://discuss.elastic.co/t/canvas-is-it-possible-to-send-varaibles-to-esql-edocs-query-argument-or-is-it-a-limitation-in-canvas/181524/1 "2019-05-17T07:03:17Z")

</div>

Will canvas support to pass the dropdown control values as variables to esql, esdocs query

filters  
| esdocs index="appscan\*" fields="url\_type\_uniqref.keyword, fversion.keyword" query="version :$var"

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [May 21, 2019, 7:28pm UTC](https://discuss.elastic.co/t/canvas-is-it-possible-to-send-varaibles-to-esql-edocs-query-argument-or-is-it-a-limitation-in-canvas/181524/2 "2019-05-21T19:28:03Z")

</div>

If you just need a single value, you can do this via filters. Basically, add a dropdown filter, bind it to the `version` field, and then on the sql element use `filters | esdocs ...`. The field value will be applied as a filter along with anything else you've added to `esdocs`.

You'll likely want to query for the values in the dropdown too, and SQL is likely the easiest way to do that. Something like `SELECT DISTINCT(version.keyword) AS version FROM "appscan*"`, then set the valueColumn to `version` and the filterColumn to `fversion.keyword`. It will show the distinct values of that field in the dropdown, and selecting a value there will apply the version filter to the field.

---

<div class="post-metadata">

**Author:** ![TEJASWI\_CHUNDURI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tejaswi_chunduri/32/46271_2.png) [@TEJASWI\_CHUNDURI](https://discuss.elastic.co/u/TEJASWI_CHUNDURI)\
**Post date:** [May 23, 2019, 8:29am UTC](https://discuss.elastic.co/t/canvas-is-it-possible-to-send-varaibles-to-esql-edocs-query-argument-or-is-it-a-limitation-in-canvas/181524/3 "2019-05-23T08:29:13Z")

</div>

Thanks Fleming ,  
Already I hade a sql way working in the same as you said .. but I need 2 version filters( dropdown) and needs to be passed to the sql .. Will can this be achieved?

---

<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:** [May 28, 2019, 8:59am UTC](https://discuss.elastic.co/t/canvas-is-it-possible-to-send-varaibles-to-esql-edocs-query-argument-or-is-it-a-limitation-in-canvas/181524/4 "2019-05-28T08:59:27Z")

</div>

Hey Joe,  
I think DISTINCT is not yet supported in elasticsearch sql querries.  
And I have a question if you please : I want to display a metric along with a dropdown filter : like for example to show the costs ... if it's on "any", I get a value. And if it's on an other field, I am getting 0.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [May 29, 2019, 5:44pm UTC](https://discuss.elastic.co/t/canvas-is-it-possible-to-send-varaibles-to-esql-edocs-query-argument-or-is-it-a-limitation-in-canvas/181524/5 "2019-05-29T17:44:15Z")

</div>

I suspect your question is related to your other question at [Canvas : Need to parse the values of 2 filters to the essql](https://discuss.elastic.co/t/canvas-need-to-parse-the-values-of-2-filters-to-the-essql/181166/3).

In short, there's not currently a way to apply filters as an OR argument in a query. What this means is that if you create two different filters and use them in the expression, they will be used as an AND condition. So this means something like `filters | essql ...`isn't an option currently.

The alternative method would be to somehow use the filter values in the sql query itself, something like `essql {string "SELECT ... WHERE " {filters | to string}} ...`. The idea is that you could capture the filter values and just use them in the query string. This is also a non-option as there's no way to map a filter's value into a string value, so it can't be substituted into the query string.

This is all a pretty round-about way to tell you you can't do what you're trying to do in Canvas, at least not today. I'll admit that this does seem like a perfectly natural request though, and I'd recommend opening an issue about it on Kibana's [issue tracker](https://github.com/elastic/kibana/issues). Supporting OR in filters would enabled what you want, without having to modify the query directly, and that seems like a feature we should add, and soon.

---

<div class="post-metadata">

**Author:** ![TEJASWI\_CHUNDURI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tejaswi_chunduri/32/46271_2.png) [@TEJASWI\_CHUNDURI](https://discuss.elastic.co/u/TEJASWI_CHUNDURI)\
**Post date:** [May 30, 2019, 11:42am UTC](https://discuss.elastic.co/t/canvas-is-it-possible-to-send-varaibles-to-esql-edocs-query-argument-or-is-it-a-limitation-in-canvas/181524/6 "2019-05-30T11:42:00Z")

</div>

Thanks Joe\_Fleming

---

<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 27, 2019, 11:42am UTC](https://discuss.elastic.co/t/canvas-is-it-possible-to-send-varaibles-to-esql-edocs-query-argument-or-is-it-a-limitation-in-canvas/181524/7 "2019-06-27T11:42:07Z")

</div>

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