# How to switch rows and columns in datatable in Canvas?

**URL:** <https://discuss.elastic.co/t/how-to-switch-rows-and-columns-in-datatable-in-canvas/185731>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [June 13, 2019, 9:45pm UTC](https://discuss.elastic.co/t/how-to-switch-rows-and-columns-in-datatable-in-canvas/185731 "2019-06-13T21:45:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [June 13, 2019, 9:45pm UTC](https://discuss.elastic.co/t/how-to-switch-rows-and-columns-in-datatable-in-canvas/185731/1 "2019-06-13T21:45:35Z")

</div>

Hello.

I would like to get help with kibana Canvas.

I have a data table as below.

 ![table](https://us1.discourse-cdn.com/elastic/original/3X/0/4/049b5996f9d000abb3d7b47730dd38c643a5623b.png)

My goal here is to create a table like below. I want to create columns according to the value of _tag\_type_.

```
shape.model first second pending
null 0 0 8851
ahead_txt 1 25 0
billboard 25 368 0

```

My current query is below.

```
filters
| essql 
  query="SELECT shape.model, tag_type, COUNT(tag_type) FROM \"tags\" WHERE tag_type IS NOT NULL GROUP BY shape.model, tag_type"
| table perPage=25
| render

```

I am thinking of _mapColumn_ might do the work but I cannot figure out the right syntax from the document.

[https://www.elastic.co/guide/en/kibana/current/canvas-common-functions.html#\_mapcolumn](https://www.elastic.co/guide/en/kibana/current/canvas-common-functions.html#_mapcolumn)

I have also checked below blog but could not find related issue.

> **[Here to Help... (An Elastic{ON} Canvas Story)](https://www.elastic.co/blog/elasticon-kibana-canvas-story-ama)**
>
> Canvas is an extensible, creative space for live data, which is exactly what we used it for at Elastic{ON} at the AMA Booth. Was your question answered?

If I can do something like below but cannot figure out how.:

`mapColumn "Status1" fn={if {getCell "tag_type" | eq "first"} then=GET COLUMN COUNT_tag_type_ else=0}`

Could some one help me out to achieve my goal ?

Thanks,  
Yu

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [June 13, 2019, 10:04pm UTC](https://discuss.elastic.co/t/how-to-switch-rows-and-columns-in-datatable-in-canvas/185731/2 "2019-06-13T22:04:54Z")

</div>

I figured it out . There was a good example on [this page](https://www.elastic.co/blog/kibana-canvas-data-table-and-debug-elements)

![ex](https://us1.discourse-cdn.com/elastic/original/3X/4/6/46ebf3e478650c1385a878b1b0a49f100f297b67.png)

---

<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, 2:59pm UTC](https://discuss.elastic.co/t/how-to-switch-rows-and-columns-in-datatable-in-canvas/185731/3 "2019-06-14T14:59:04Z")

</div>

Glad you figured it out and that we had a doc that was helpful!

---

<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 12, 2019, 2:59pm UTC](https://discuss.elastic.co/t/how-to-switch-rows-and-columns-in-datatable-in-canvas/185731/4 "2019-07-12T14:59:05Z")

</div>

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