Applying CASE function to JSON datasource - possible?

Hi,
I’m creating dashboard displaying information from RestApi call to Maximo via Infinity DataSource.
Result coming to Grafana as JSON looks like in below example (I’ve limit it to important stuff)

{
    "member": [
        {
            "targstartdate": "2025-03-10T00:00:00+00:00",
            "reportdate": "2025-02-17T09:15:35+00:00",
            "wonum": "FI8504117"
        },
        {
            "targstartdate": "2025-03-10T00:00:00+00:00",
            "reportdate": "2025-02-17T09:05:04+00:00",
            "wonum": "FI8503542",
            "schedstart": "2025-03-12T12:00:00+00:00"
        }
}

and I’m first executing simple UQL parsing against it

parse-json 
| project "member"  
| project "wonum","schedstart","reportdate","targstartdate"

and further apply setup, formatting and colouring by Grafana features.

The thing and help I need is some combination to display schedstart and targstartdate.
I have a requirement that I should display only one date, meaning - display schedstart if it’s not null, otherwise, display targetstartdate.

Having that in SQL I would easily use a case function writing:

CASE WHEN SCHEDSTART IS NOT NULL THEN SCHEDSTART ELSE TARGSTARTDATE END

But I cannot do such thing for JSON output.

Do you know if is there any way (UQL function, Transformation, etc.) which I can have a result similar to above CASE expression?

Thanks in advance for any help!

Sorted this out already with JSONata.

$.member.{
    'wonum':wonum,
    'date':schedstart != null ? schedstart : targstartdate
}
1 Like