Chooses between two expressions depending on whether the condition is true or false.
For example, @if score >= 0 @then "Positive" @else "Negative" @endif
would check whether the score expression is greater than or equal to zero. If it
was, the result would be the "Positive" text; otherwise it would be the "Negative"
text.
Matches against several possible alternatives. For example, @match desc @case "full" @orcase "max" @then 1.0 @case _ @then 0.5 @endmatch
checks if desc is equal to "full" or "max". If so, the result is 1.0, otherwise
(the case underscore matches anything else) the result is 0.5.
Defines a name for a value, to allow later use. Often you may find yourself repeating the same piece of code, which is both tiresome to enter, and awkward when you need to edit it in multiple places later. By defining a name for the shared code, it's easier to reference and edit.
Another use for definitions is to do pattern matching, especially for things like
optional types; for example @define Is(x) = Column with optional type @then x @enddefine
Makes a function. The comma-separated list of parameters goes after the function\\keyword, and the body of the function goes after the @then. Functions are very often used with @define, which allows you to name and re-use the function.
If the function you need is very simple and uses its parameter once, you may find the quest syntax useful.
Sometimes you want a function that does something very simple, like adding one to
a number. The full function syntax is cumbersome for this. Instead you can write (? + 1)
, which is a function with a single parameter that adds one to get the result. If
you have multiple question marks, e.g. ? * ?
, the function has as many parameters as there are question marks.
The function extends to the single expression that the question mark(s) appear in.
So 0 <= ? < ? <= 1
takes two parameters and checks that the first is less than the second, and they
are both between zero and one. The expression (? + 1) * 2
is a type error because you can't multiply a function like two (use the full function
syntax instead).
A count of the number of items that collapsed into the destination row. The aggregate expression can either be calculated once for the whole source table (in which case this variable is the length of the source table) or split by row values.
For example, if you split by a boolean column Winning, there will be one aggregated row for all the rows in the source table where Winning was true -- and there, group count will be the number of rows in the source table where Winning was true.
If you want a frequency table, using group count by itself will produce the right result.
The number of the current row. The first row is 1, the second row is 2 and so on.