IF in query

How can I create a conditional column in a query?

Try 1 does not work:

${query[[
from index.tag "task"
select { 
  name, 
  due, 
  X = if(name == "appel", "1", "0") 
}
]]}

try 2 does not work:

${query[[from index.tag "task" 
select { name, due, 
  X=(name == "appel" ? "1" : "0") }
]]}

I have something similar implemented to show different emojis(:red_circle:,:orange_circle:,:yellow_circle:,:green_circle:) for different values of stat attribute using following synthax:

${query[[
from index.tag "todo"
where date and date.startsWith("2026")
select {
  Name = "[[" .. ref .."|".. name.. "]]",
  Status = (
    stat == "1" and "🔴" or
    stat == "2" and "🟠" or
    stat == "3" and "🟡" or
    stat == "4" and "🟢" or
    stat)
}
order by date
]]}

so basically for your query the correct synthax should be something like this:

${query[[
from index.tag "task"
select { 
  Name = "[[" .. ref .."|" .. name .."]]",
  Due = due, 
  X = ( name == "appel" and "1" or  "0") 
}
]]}

you were pretty close with your second try...

Or did you wanted to show/hide a column based on the X-value. it isn't 100% clear to me. I don't quite get what you mean by conditional column "1" and "0"