KQL formula in vega lite

Hi Team,

I'm trying to plot a line graph using vega-lite. How to give KQL formulas in vega-lite. I used field called "claculate" but may be my syntax is wrong. Please help on creating line graph.

  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "title": "Performance metrics",
  "data": {
    "url": {
      "%context%": true,
      "%timefield%": @timestamp,
      "index": "bkp-ispfw-15032023"
  "transform": [
      "calculate": "count(kql='Status: \"TP\"')/(count(kql='ValidGTPoint:\"True\"'))", "as": "PDJ Score" 
  "mark": {
    "type": "line",
    "point": true
  "encoding": {
    "x": {"timeUnit": "year", "field": "date"},
    "y": {"aggregate":"mean", "field": "price", "type": "quantitative"},
    "color": {"field": "symbol", "type": "nominal"}

Error its not showing which line and any other details. Just giving below error.
Unexpected token =

Thanks in advance.

Hi @Nanditha

it looks like you are using a Lens formula within a Vega context: that is not possible as formula is a Lens specific feature.
You have to manually create a query to retrieve 2 filtered counts, and then perform the Vega calculation on the fields.

Can you please show me an example or any link to explain.

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