mvexpand metrics | spath input=metrics | rename "cityCode" as pcc | where if($selected_pcc|s$="all",like(pcc,"%"),like(pcc,$selected_pcc|s$)) | stats count as Total
I use the command above to filter the result by looking into the json field cityCode, and verify if the value equals to my dropdown value selection, by default all cityCode would be included ( % ).
The issue is when the message does not have the cityCode field, the default select All cityCode will not work since the like (pcc,"%") would fail.
Currently, the conditional selection is inside the where clause, Is there a way to do conditional selection outside the where clause, meaning if I did not select cityCode, the where clause should be ignored completely.
... View more