Mathieu
Mathieu

Reputation: 98

Elastic Canvas date formatting

I'm trying to format date in a Kibana Canvas, so I followed this documentation: https://www.elastic.co/blog/kibana-canvas-data-table-and-debug-elements

But the example is fails, using:

| mapColumn Time fn={ date | formatdate “hh:mm A” }

replace my columns with current date but not query result date.

Someone have the good way to format date?

Here is the full expression:

filters
| essql 
  query="SELECT 
MAX(\"occurred\") AS MAX_DATE_TIME,
MIN(\"occurred\") AS MIN_DATE_TIME
FROM \"elastic_reports_index\""
| mapColumn "MIN_DATE_TIME" fn={date | formatdate "DD/MM/YYYY"}
| mapColumn "MAX_DATE_TIME" fn={date | formatdate "DD/MM/YYYY"}

Upvotes: 2

Views: 1540

Answers (1)

scottfrenz
scottfrenz

Reputation: 51

I ran into the same issue and had to use getCell (taken from https://discuss.elastic.co/t/canvas-does-not-recognize-date-field/127095/6).

Try:

| mapColumn "MIN_DATE_TIME" fn={getCell MIN_DATE_TIME | formatdate "DD/MM/YYYY"}
| mapColumn "MAX_DATE_TIME" fn={getCell MAX_DATE_TIME | formatdate "DD/MM/YYYY"}

Upvotes: 3

Related Questions