# Map column from tiny math result

**URL:** <https://discuss.elastic.co/t/map-column-from-tiny-math-result/251691>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [October 11, 2020, 8:34pm UTC](https://discuss.elastic.co/t/map-column-from-tiny-math-result/251691 "2020-10-11T20:34:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugo\_Pires](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo_pires/32/68069_2.png) [@Hugo\_Pires](https://discuss.elastic.co/u/Hugo_Pires)\
**Post date:** [October 11, 2020, 8:34pm UTC](https://discuss.elastic.co/t/map-column-from-tiny-math-result/251691/1 "2020-10-11T20:34:24Z")

</div>

Hello

Is it possible to create a new column in a data table using mapcolumn and a tinymath that divides two existing ones?

Thank you

Hugo

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [October 12, 2020, 5:51pm UTC](https://discuss.elastic.co/t/map-column-from-tiny-math-result/251691/2 "2020-10-12T17:51:46Z")

</div>

Hi Hugo. can you do the division in the query to create a new column? For example, from [the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-syntax-select.html#sql-syntax-having):

```auto
SELECT MIN(salary) AS min, MAX(salary) AS max, MAX(salary) - MIN(salary) AS diff FROM emp GROUP BY languages HAVING diff - max % min > 0 AND AVG(salary) > 30000;

```

---

<div class="post-metadata">

**Author:** ![Hugo\_Pires](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo_pires/32/68069_2.png) [@Hugo\_Pires](https://discuss.elastic.co/u/Hugo_Pires)\
**Post date:** [October 13, 2020, 8:42pm UTC](https://discuss.elastic.co/t/map-column-from-tiny-math-result/251691/3 "2020-10-13T20:42:29Z")

</div>

Thanks @nickpeihl

It would be a great idea, but since I am using a PIVOT I am facing this [bug](https://github.com/elastic/elasticsearch/issues/49163)

Nevertheless, It raises an usual question for me when using Canvas: should I use SQL, Canvas functions, Tiny math, or Markdown iteration - sometimes it's possible to do it using any of these tools.

---

<div class="post-metadata">

**Author:** ![Hugo\_Pires](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo_pires/32/68069_2.png) [@Hugo\_Pires](https://discuss.elastic.co/u/Hugo_Pires)\
**Post date:** [October 13, 2020, 9:10pm UTC](https://discuss.elastic.co/t/map-column-from-tiny-math-result/251691/4 "2020-10-13T21:10:13Z")

</div>

Probably I would have the same problem since I am using Pivot columns in a tiny math expression like this

```auto
    mapColumn "racio" exp={math "divide('First column','Second column')"}

```

---

<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:** [November 10, 2020, 9:10pm UTC](https://discuss.elastic.co/t/map-column-from-tiny-math-result/251691/5 "2020-11-10T21:10:25Z")

</div>

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