Hi,
I am using Infinity datasource to import my csv file. i am UQL query to columns.
I have variable created “Label”. Which as 2 or more values.
Now wrote a below query to call the columns based on the condition selected in variable,
parse-csv
| where “Label” == ‘${label}’
| if “Label” == “Prod” | project “Column1”, “Column2”
|elseif "Label == “Shadow” | project “Column3”, “Column3”
But this code is not working. Please do give correct code to call the columns based on the value selected in variable.
Thanks
i am not seeing the if elseif in the uql documentation
https://grafana.github.io/grafana-infinity-datasource/docs/uql
you might need to go the jsonata route to do such conditional column selection
Can you please give the correct code for my above condition if feasible?
This will help me understand the jsonata better.
Thank you for the reply.
well, probably best for you to try it out in jsonata and then when you are stuck let us know
it will be good to learn jsonata
I already tried many things in jsonata. Tried many things in last 3 days. Nothing is working.
It would be very helpful if you can help with this, so I can try for others.
share what you have tried with jsonata and we can go from there
parse-csv
| “Label” == ‘${label}’
| jsonata [${Label} == “Prod”] | project “Timestamp”
| jsonata [${Label} == “Shaow”] | project “Time”
Tried if other things as well. Tried where statements. Tried Extend statements.
Nothing is working for this case. Please help me with this.
Hi,
Anything you can guide me here?
Thanks
please provide sample json data you are querying as csv inline text not as an image
I am using csv file here.
Examaple:
Timestamp,Time,Value
01-02-2024,12-03-2024,1
02-02-2024,13-03-2024,2
So here I have a variable “Lable” which has 2 values. When I select “Prod” I need to pull column “Timestamp”. When I select “Shadow” I need to pull column “Time”. For this I used below code as well as Where,
parse-csv
| “Label” == ‘${label}’
| jsonata [${Label} == “Prod”] | project “Timestamp”
| jsonata [${Label} == “Shaow”] | project “Time”
Still doesn’t work.