# Kibana Canvas

**URL:** <https://discuss.elastic.co/t/kibana-canvas/313786>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [September 6, 2022, 11:38am UTC](https://discuss.elastic.co/t/kibana-canvas/313786 "2022-09-06T11:38:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![RobinIT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robinit/32/57833_2.png) [@RobinIT](https://discuss.elastic.co/u/RobinIT)\
**Post date:** [September 6, 2022, 11:38am UTC](https://discuss.elastic.co/t/kibana-canvas/313786/1 "2022-09-06T11:38:55Z")

</div>

Hello,

I have a dashboard with a Pie, including some filters to specify the Slices of the pie.

I want to build the Pie in canvas, but I don't know how. Can someone guide me a little bit, with some hints....how to get the filters for the slices in a canvas Pie.

I allready studied the online documentation, some example make it more clear.

Thanks.

Greeting,  
Robin

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [September 6, 2022, 3:37pm UTC](https://discuss.elastic.co/t/kibana-canvas/313786/2 "2022-09-06T15:37:44Z")

</div>

Not sure what you mean for `filters to specify the Slices of the pie` but assuming you want to aggregate some index by a field and get the count of documents per field value and then filter out some values you want to hide, I think you can use the [`filterrows`](https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html#filterrows_fn) function in Canvas or maybe simply put a `WHERE` condition in your SQL clause.

In this screenshot I get from the flights sample data set a count of documents per `Carrier` and then in the expression editor I added a `filterrows` to only keep those for `JetBeats` and `ES-Air`

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

But as I was mentioning, you can do the same from the source just adding a `WHERE` clause

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/f/2f762d9de9f4ba61377bf2f270dd9443396b5c33.png)

Does this help?

---

<div class="post-metadata">

**Author:** ![devon.thomson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/devon.thomson/32/85468_2.png) [@devon.thomson](https://discuss.elastic.co/u/devon.thomson)\
**Post date:** [September 6, 2022, 4:26pm UTC](https://discuss.elastic.co/t/kibana-canvas/313786/3 "2022-09-06T16:26:36Z")

</div>

It's also important to note that you can use the pie visualization from the Dashboard directly on the Canvas. You can either save it to the visualization library, and use the `Add from library` button on the workpad, or create the pie chart again in Lens or Visualize by navigating to the editor directly from the Canvas top bar, then pressing `Save and return` once you've configured your pie chart.

---

<div class="post-metadata">

**Author:** ![RobinIT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robinit/32/57833_2.png) [@RobinIT](https://discuss.elastic.co/u/RobinIT)\
**Post date:** [September 6, 2022, 7:53pm UTC](https://discuss.elastic.co/t/kibana-canvas/313786/4 "2022-09-06T19:53:22Z")

</div>

This is a really good one to remember, thank you 🙂

---

<div class="post-metadata">

**Author:** ![RobinIT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robinit/32/57833_2.png) [@RobinIT](https://discuss.elastic.co/u/RobinIT)\
**Post date:** [September 6, 2022, 8:00pm UTC](https://discuss.elastic.co/t/kibana-canvas/313786/5 "2022-09-06T20:00:15Z")

</div>

Yes, this helped me, I need to understand the way off thinking with canvas.

I only need to combine two or more values to one slice.

Lets say I have a column with multiple values: 1,2,3,4

Then I want to add the values 1 in one slice and the values 2,3 grouped in one slice and 4 in one slice.

Thank you for your assistance. 🙂

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [September 7, 2022, 9:35am UTC](https://discuss.elastic.co/t/kibana-canvas/313786/6 "2022-09-07T09:35:43Z")

</div>

This Canvas expression worked for me with the sample flights dataset

```auto
kibana
| selectFilter
| essql 
  query="SELECT Carrier, count(1) as count
FROM \"kibana_sample_data_flights\"
GROUP BY Carrier"
| mapColumn name="newCarrier" id="newCarrier" expression={
  if condition={getCell Carrier | any {eq "JetBeats"} {eq "ES-Air"}}
    then= "JetBeats and ES-Air"
    else= { getCell Carrier }
}
| pointseries color="newCarrier" size="sum(count)"
| pie
| render

```

It uses [`mapColumn`](https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html#mapColumn_fn) to define a new column in the data table that merges the rows for `JetBeats` and `ES-Air`. Then you also need to change the `pointseries` call to use the `sum(count)`.

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

---

<div class="post-metadata">

**Author:** ![RobinIT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robinit/32/57833_2.png) [@RobinIT](https://discuss.elastic.co/u/RobinIT)\
**Post date:** [September 7, 2022, 11:04am UTC](https://discuss.elastic.co/t/kibana-canvas/313786/7 "2022-09-07T11:04:43Z")

</div>

I fixed it with a CASE function, worked good.

I don't know if this is off topic, but I do have a last challenge to solve, and I think I need the mapColumn for this but I do not exactly know if it is possible.

Let me tried to explain it:

I have a table, table A, inlcuding names, created with an ESSQL query from index A, I need to check if the names in that table are in another INDEX, INDEX B. And I want the result in a column in A. I'm stuck, I think I need to use the getCell function, that you used aswell and pipe it to an other ESSQL query to perform the search, but it is not working, I miss something. This is what I have so far:

```nohighlight
| essql 
  query="SELECT target as Hosts FROM INDEXA WHERE \"@timestamp\" >= (TODAY() - INTERVAL 7 DAY)"
  mapColumn name="Amount" id="Amount" expression={getCell Hosts | essql query='SELECT count(Bug) FROM "INDEXB" WHERE \"@timestamp\" >= (TODAY() - INTERVAL 7 DAY) AND target = Hosts'} 
| render

```

I get the error:  
[essql] \> Unknown argument 'name' passed to function 'essql'

In the end I want add a couple columns like this and make a Pie out of it.

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [September 7, 2022, 11:38am UTC](https://discuss.elastic.co/t/kibana-canvas/313786/8 "2022-09-07T11:38:01Z")

</div>

Maybe you are lacking a `|` before the `mapColumn` statement?

Also, using `render as=debug` seems to be useful to see the data structures (I just learnt this today 😅 )

---

<div class="post-metadata">

**Author:** ![RobinIT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robinit/32/57833_2.png) [@RobinIT](https://discuss.elastic.co/u/RobinIT)\
**Post date:** [September 7, 2022, 11:59am UTC](https://discuss.elastic.co/t/kibana-canvas/313786/9 "2022-09-07T11:59:49Z")

</div>

Yes, I checked it, it is there

---

<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:** [October 5, 2022, 12:00pm UTC](https://discuss.elastic.co/t/kibana-canvas/313786/10 "2022-10-05T12:00:16Z")

</div>

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