Conditional formatting for Metric (empty field)

Hi,

I'm creating a dashboard using Lens, and I'm reading the Last Value of a field that indicates the number of documents seen.

Currently, I have set the visualization to be a Metric that shows the number of documents, and have colored the background such that it is green when the value is more than 1000. There are times when no document is seen, as the field doesn't exist (in case of error). In this case, the value in the dashboard becomes - and the background is simply white. How do I set the background to red in such cases? I think that the color range starts from 0, and doesn't seem to cover the case where there is no value (i.e. field value does not exist).

Thank you.

Hi @hjazz6

unfortunately Color by value feature in Lens is not able yet to handle null values.
Your best option here is to convert the null value into 0, then the color mapping will work: to make that you can use a formula like defaults(last_value(my_field), 0).

1 Like