# Updating table column values e.g. status using a SQL query meeting a condition

**URL:** https://discuss.elastic.co/t/updating-table-column-values-e-g-status-using-a-sql-query-meeting-a-condition/335664
**Category:** Kibana
**Tags:** canvas
**Created:** [June 9, 2023, 10:40pm UTC](https://discuss.elastic.co/t/updating-table-column-values-e-g-status-using-a-sql-query-meeting-a-condition/335664 "2023-06-09T22:40:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Raj\_obsv](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@Raj\_obsv](https://discuss.elastic.co/u/Raj_obsv)
#### Post date: [June 9, 2023, 10:40pm UTC](https://discuss.elastic.co/t/updating-table-column-values-e-g-status-using-a-sql-query-meeting-a-condition/335664/1 "2023-06-09T22:40:56Z")

</div>

In canvas I have a requirement to display couple of Job status of last 30 days which frequency is daily however on some days 2-3 jobs are not schedule. As expected no timestamp or any entry will be created in elastic for not running jobs. I want to create a last 30 days view to provide the job status it picks the dates when there is an entry, however, not able to highlight the date or an entry which says that job was not executed on that given date. E.g, if a view is created for job execution for last 5 days and considering on Tue it was not executed I will get  
Days | Status  
05-Jun-2023 | Success  
07-Jun-2023 |Success  
08-Jun-2023 |Success  
09-Jun-2023 | Delay

But my requirement is to display as  
Days | Status  
05-Jun-2023 | Success  
**06-Jun-2023 | Not Executed**  
07-Jun-2023 |Success  
08-Jun-2023 |Success  
09-Jun-2023 | Delay

I am creating the dates using the CSV and map column so that I have an entry for all the 5 days and then trying to run the query to fetch the status from the elastic

I used below query but got below error  
_Expression failed with the message:_

_[mapcolumn] \> [switch] \> [case] \> [eq] \> [essql] \> Unexpected error from Elasticsearch: ql\_illegal\_argument\_exception - Line 8:22: Comparisons against fields are not (currently) supported; offender [cast( Concat( DATETIME\_FORMAT("@timestamp",'YYYY-MM-dd'), 'T05:30:00.000' ) AS DATETIME)] in [\<]_

Please advise how to fetch status using the query by filtering/comparing against the dates in the table created.

Also is it possible to create a Grid view for below data

Day | Job 1 Status | Job 2status  
05-Jun-2023 | Success | Success  
06-Jun-2023 | Not Executed | Success  
07-Jun-2023 |Success |Delay  
08-Jun-2023 |Success |Not Executed  
09-Jun-2023 | Delay |Success

//  
\</\>  
filters ungrouped=true  
| csv  
"Day,col, SLA\_STAUS  
1,86400000,NotExecuted  
2,86400000,NotExecuted  
3,86400000,NotExecuted  
4,86400000,NotExecuted  
5,86400000,NotExecuted  
6,86400000,NotExecuted  
7,86400000,NotExecuted  
8,86400000,NotExecuted  
9,86400000,NotExecuted  
10,86400000,NotExecuted  
| alterColumn "Day" type="number"  
| alterColumn "col" type="number"  
| mathColumn id="DayMilSec" name="DayMilSec" expression="Day_col"  
| mapColumn name="formatteddate" expression={date}  
| mathColumn id="DateU" name="DateU" expression="formatteddate - DayMilSec"  
| mapColumn name="formatteddateU" expression={getcell "DateU" | formatdate format="DD MMMM YYYY"}  
|mapcolumn name="SLA\_STATUS"  
expression={ getcell "formatteddateU" |  
switch {case if={eq {filters|essql {string "  
Select DATETIME\_FORMAT("@timestamp",'DD MMMM YYYY')  
FROM "index1_"  
where "job.status" = 'SUCCESS'  
AND "@timestamp" \< cast( Concat( DATETIME\_FORMAT("@timestamp",'YYYY-MM-dd'), '" {var "METSLATime"} "' ) AS DATETIME)  
and "job.name" LIKE 'job/\_test' ESCAPE '/' Order by "@timestamp"  
"}  
}  
} then="green"}  
default="Red"  
}  
| table  
\</\>  
//

---

<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 7, 2023, 10:41pm UTC](https://discuss.elastic.co/t/updating-table-column-values-e-g-status-using-a-sql-query-meeting-a-condition/335664/2 "2023-07-07T22:41:45Z")

</div>

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