sisense.com

JAQL Syntax Reference

Properties

NameTypeRequiredDescriptionDefault
datasourcestring or objectYesStates the connection (ElastiCube) name against which to execute the query.N/A
metadataobject[]YesContains an array of JAQL elements. A JAQL element is essentially dimension or measure.N/A
formatstringNoStates the expected query result data type; CSV or JSON"json"
offsetnumberNoCuts the query result by setting the row offset and row countundefined
countnumberNoCuts the query result by setting the row offset and row countundefined
csvSeparatorstringNoDefines the CSV separator that is used when rendering the CSV query result","
isMaskedResponsebooleanNoWhether returned values are formatted. When true, values will be objects with a data+text property pair.true

Datasource

The datasource property tells Sisense which Data Model the query should run against.

Tips

You can use the

endpoint to get a list of objects in this format for each of the Data Models available on your environment.

Properties

NameTypeRequiredDescription
titlestringYesName of Data Model to query
fullnamestringNoInternal use (not required)
idstringNoInternal use (not required)
addressstringNoInternal use (not required)
databasestringNoInternal use (not required)

Example

{
    "title": "Sample Healthcare",
    "fullname": "LocalHost/Sample Healthcare",
    "id": "localhost_aSampleIAAaHealthcare",
    "address": "localHost",
    "database": "aSampleIAAaHealthcare"
}

Metadata Items

This array specifies all of the dimensions (columns), measures (aggregations) and filters that will participate in the query, whether they are part of the result set or not.

Each item in the array (aka MetadataItem) represents one dimension/measure/filter.

Please Note

Each MetadataItem regardless of content has the following structure:

{
    "jaql": {
        // Query properties here
    },
    // Other properties
}

The sections below will describe the contents of the jaql property - there are other properties used internally which do not need to be provided.

Dimensions

Properties

NameTypeRequiredDescription
dimstringYesThe dimension name
levelstringNoStates the date level in a Date dimension
filterobjectNoDefines the element's filter

Supported Date Levels

  • years
  • quarters
  • months
  • days
  • hours
  • minutes
  • timestamp

Example

{
    "jaql": {
         "dim": "[Users.CreatedOn (Calendar)]",
        "level": "days"
    }
}

Simple Aggregations

Properties

NameTypeRequiredDescription
dimstringYesThe dimension name
levelstringNoStates the date level in a Date dimension
aggstringYesDefines the measure aggregation over the dimension defined in the dim property
filterobjectNoDefines the element's filter

Supported Aggregations

  • avg
  • count
  • countduplicates
  • min
  • max
  • median
  • stdev
  • stdevp
  • sum
  • var
  • varp

Example

{
    "jaql": {
        "dim": "[Users.ID]",
        "agg": "count"
    }
}

Formulas

Properties

NameTypeRequiredDescription
formulastringYesDefines the formula string
contextobjectYesDefines the context of the dimensions used in the formula

Example

{
    "jaql": {
        "formula": "count([users]) / 10",
        "context": {
            "users": {
                "dim": "[Users.ID]"
            }
        }
    }
}

Filtering

In JAQL, filters are created by adding a filter property to the MetadataItem as follows:

{
    "jaql": {
        "dim": "[Table.Column]",
        "filter": {
            // Filter properties go here
        }
    }
}

Please Note

For brevity, the sections below describe the inner contents of the filter property without specifying the surrounding Metadata in its entirety

Foreground vs Background Filtering

There are 2 possible behaviors for filters:

Foreground filters are filters applied to a dimention that participates in the query, and are part of the result set.

For example, consider this query:

[{
    "jaql": {
        "dim": "[Customers.Country]"
    }
},
{
    "jaql": {
        "dim": "[Customers.ID]",
        "agg": "count"
    }
}]

This query will return a list of countries, with how many customers exist in each country.

By adding a filter to the participating Country dimension, we create a foreground filter - the result set will include only one row, as the filter only allows the inclusion of one country:

{
    "jaql": {
        "dim": "[Customers.Country]",
        "filter": {
            "members": ["Ukraine"]
        }
    }
}

Background Filters are filters on a dimension that does not participate in the query result, which can be created by specifying the MetadataItem property panel: scope.

For example, this query will return a list of countries with a count of users in each country, but only counting the active users.
There will be no Active column in the result set, and it will not be used to group data.

[{
    "jaql": {
        "dim": "[Customers.Country]"
    }
},
{
    "jaql": {
        "dim": "[Customers.ID]",
        "agg": "count"
    }
},{
    "jaql": {
        "dim": "[Customers.Active]",
        "filter": {
            "members": ["Yes"]
        }
    },
    "panel": "scope"
]

Members

Supported Datatypes: text, number, datetime

Filter by specific unique values of the dimension

Properties

NameTypeRequiredDescription
membersstring[]YesAn array of values

Example

{
    "members": ["USA", "China"]
}

Text Filters

Supported Datatypes: text

Supported Filters

  • equals
  • doesntEqual
  • contains
  • doesntContain
  • startsWith
  • doesntStartWith
  • endsWith
  • doesntEndWidth
  • like

Example

{
    "equals": "USA"
}

Mathematical Filters

Supported Datatypes: number, datetime

Supported Filters

  • equals
  • doesntEqual
  • from
  • fromNotEqual
  • to
  • toNotEqual

Example

{
    "equals": 42
}

Relative Date Filters

Supported Datatypes: datetime

Supported Filters

  • last
  • next

Properties

NameTypeRequiredDescription
countnumberNoHow many time units to include. Defaults to 1
offsetnumberNoHow many time units to skip. Defaults to 0
anchorstringNoSet a custom date to calculate from. Can also be first or last.

Example

{ 
    "last":{ 
        "count": 5,
        "offset": 10
    }
}

Top/Bottom Filters

Supported Datatypes: text, number, datetime

Supported Filters

  • top
  • bottom

Properties

NameTypeRequiredDescription
top or bottomnumberYesHow many items to include
byobjectYesA JAQL aggregation object (dim+agg or formula+context)

Example

{ 
    "top": 2,
    "by": { 
        "dim": "price",
        "agg": "sum"
    }
}

Negative Filters

Example

{ 
    "exclude": { 
        "members": [ 
            "London",
            "Paris"
        ]
    }
}

Combining Filters

Supported Filters

  • and
  • or

Example

{ 
    "or":[ 
        { 
            "like": "%acer%"
        },
        { 
            "contains": "toshiba"
        }
    ]
}
Last Updated: