# Canvas does not recognize Date field

**URL:** <https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095>\
**Category:** Kibana\
**Created:** [April 6, 2018, 12:52pm UTC](https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095 "2018-04-06T12:52:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinVarbanov](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@MartinVarbanov](https://discuss.elastic.co/u/MartinVarbanov)\
**Post date:** [April 6, 2018, 12:52pm UTC](https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095/1 "2018-04-06T12:52:39Z")

</div>

I am running canvas for Kibana 6.2.3. There is a date field "Activity month" which is working fine if I build Bar charts in Kibana. However Canvas does not recognize "Activity month" as a date filed and I cannot build visualization correctly. Any suggestion how to resolve this issue?

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [April 9, 2018, 3:02pm UTC](https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095/2 "2018-04-09T15:02:04Z")

</div>

@rashid / @Joe_Fleming thanks!

---

<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:** [April 10, 2018, 4:21pm UTC](https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095/3 "2018-04-10T16:21:33Z")

</div>

What type of field does Canvas think it is? And what's the mapping for the field (you can check in Kibana, or use the mapping api)?

I also wonder if perhaps the format on the date field is different than what Canvas is expecting somehow. If you could just use the `esdocs` function to get some data and post a screenshot of the table output, that would be helpful too.

---

<div class="post-metadata">

**Author:** ![MartinVarbanov](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@MartinVarbanov](https://discuss.elastic.co/u/MartinVarbanov)\
**Post date:** [April 11, 2018, 8:56pm UTC](https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095/4 "2018-04-11T20:56:04Z")

</div>

I am not using special mapping. The data is loaded with logstash using  
`stdout { codec => json_lines }`

According to the coordinate plot it seems the "activity month" is a float between -1 and 1.  
I am using the following code:

> ```
> filters | esdocs index="wbs*" | pointseries x="activity month" y="sum(total_activity_hours)" color="hml" | plot defaultStyle={seriesStyle points=5} | render
> 
> ```

 ![Kibana3](https://us1.discourse-cdn.com/elastic/original/3X/0/f/0f007f36f653b11efd9c6d55e09b7d7cc8e2999e.JPG)

Kibana shows:

 ![Kibana2](https://us1.discourse-cdn.com/elastic/original/3X/5/c/5c2009cdbb687881b0378ea8c2e418256b3e005a.JPG) ![Kibana1](https://us1.discourse-cdn.com/elastic/original/3X/e/c/ec34bda0433c309a76a7468c18196043569d42c7.JPG)

---

<div class="post-metadata">

**Author:** ![MartinVarbanov](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@MartinVarbanov](https://discuss.elastic.co/u/MartinVarbanov)\
**Post date:** [April 11, 2018, 9:50pm UTC](https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095/5 "2018-04-11T21:50:32Z")

</div>

The format of the "activity month" is the same as the "@timestamp" but if I build coordinate plot with the "@timestamp" is it working correctly vs. the "activity month".

Example of single document:  
{  
"\_index": "wbs",  
"\_type": "doc",  
"\_id": "UHFftmIBjBO9JUeJhxsK",  
"\_score": 1,  
"\_source": {  
"activity month": "2018-03-01T00:00:00.000Z",  
"total\_activity\_hours": 8,  
"hml": "High",  
"@timestamp": "2018-04-11T20:22:16.130Z"  
},  
"fields": {  
"activity month": [  
"2018-03-01T00:00:00.000Z"  
],  
"@timestamp": [  
"2018-04-11T20:22:16.130Z"  
]  
}  
}

---

<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:** [April 13, 2018, 6:28pm UTC](https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095/6 "2018-04-13T18:28:58Z")

</div>

I figure out the issue. There's a problem in Canvas where it doesn't handle field names with spaces correctly. I'll get a fix in, and hopefully ship it in the next version.

In the meantime, you can use [alterColumn](http://canvas.elastic.co/reference/functions.html#altercolumn) to rename the column, like so:

```auto
filters | esdocs index="wbs*" 
| alterColumn "activity month" name=activity_month
| pointseries x=activity_month y="sum(total_activity_hours)" color="hml" 
| plot defaultStyle={seriesStyle points=5} 
| render

```

You can see the issue if you break the expression down:

 ![41](https://us1.discourse-cdn.com/elastic/original/3X/d/1/d12112b80e9f25377e83a5eb0bbafc34f546edbc.png)

Here, I've split up each of the parts of the expression, starting with the data, then just the `pointseries`, and finally the whole thing with `plot`. Notice how the column for the `pointseries` output has a question mark. This means that it doesn't know what type of data is in there, and when `plot` tries to use it, it ends up treating the value as a number, resulting in 0... kind of.

When you rename the column you get a different outcome:

 ![47](https://us1.discourse-cdn.com/elastic/original/3X/d/9/d9e7d48f1635e9ee0389f75d69f2e904018ddc20.png)

With the space removed from the column name, `pointseries` now correctly assigns the output type as a string, and `plot` knows how to correctly handle the data.

You can go even further and cast the value into an actual month name, using [mapColumn](http://canvas.elastic.co/reference/functions.html#mapcolumn):

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

```auto
filters | esdocs index="wbs*" 
| alterColumn "activity month" name=activity_month
| mapColumn activity_month expression=${getCell activity_month | formatdate "MMM"}
| pointseries x=activity_month y="sum(total_activity_hours)" color="hml" 
| plot defaultStyle={seriesStyle points=5} 
| render

```

Hope that's all 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:** [May 11, 2018, 6:29pm UTC](https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095/7 "2018-05-11T18:29:09Z")

</div>

Closed on May 11, 2018, 6:29pm UTC

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