QUERY Function
Summary
- The
QUERYExpression Function in AdapTableQL supports referencing Named Queries in Expressions - Named Queries can return either any value, boolean, numeric, text, data etc.
The QUERY Expression Function enables referencing Named Queries inside Expressions.
Note
- A Named Query is an Expression that has been named and saved into Query State for subsequent re-use
- It can resolve to any value - a Boolean, number, text or date
The referenced Query is identified by its name and it is evaluated on the fly by AdapTableQL.
QUERY returns whatever value the referenced Named Query resolves to.
So a Boolean Named Query can be combined with other Boolean logic, while a scalar (e.g. numeric) Named Query can be used anywhere a value is expected - for example inside a Calculated Column.
So the Expression below could be saved as a Named Query called 'Big Orders'
[ItemCount] > 30 OR [OrderCost] > 500And this Named Query can now be referenced as follows:
QUERY("Big Orders") AND [Currency] = 'USD'A scalar Named Query works the same way — save a value Expression, then reference it with QUERY wherever a value is expected (including inside another Boolean Expression):
// Named Query "Popularity Score" = PRODUCT([github_stars], [github_watchers], [open_issues_count])
QUERY("Popular Frameworks") AND QUERY("Popularity Score") > 1000000000Caution
- A Named Query is treated as boolean unless it declares a
ReturnType - A scalar Named Query must set its return type, e.g.
ReturnType: 'number'orReturnType: 'text'
NamedQuery: {
NamedQueries: [{
Name: 'Popularity Score',
Expression: 'PRODUCT([github_stars], [github_watchers], [open_issues_count])',
ReturnType: 'number',
}],
},AdapTableQL: QUERY Expression Function
- This Example demonstrates how to use the
QUERYExpression Function - 2 Named Queries are provided:
Popular Frameworks(boolean):[github_watchers] > 2000 OR [github_stars] > 14500Popularity Score(numeric scalar):PRODUCT([github_stars], [github_watchers], [open_issues_count])
- These Named Queries are then referenced using the
QUERYkeyword:- A Custom Report has the Expression:
QUERY("Popular Frameworks") - A Calculated Column has the Expression:
QUERY("Popularity Score") - A Format Column Condition has the Expression:
QUERY("Popular Frameworks") AND QUERY("Popularity Score") > 1000000000 AND [has_wiki] - A Data Change Alert has the Expression:
QUERY("Popular Frameworks") AND [language]="JavaScript"
- A Custom Report has the Expression:
Try It Out
- Edit either Named Query (through the
Named QuerySection in Settings Panel) and see how the Style / Calculated Column values change - Change
Has Wikiin rows with JavaScript and see the Alert appear; do the same in rows with TypeScript and note there is no Alert
Loading demo…