Multidimensional Analytical Query Language (MAQL)

Multidimensional Analytical Query Language, or MAQL for short, is the GoodData’s proprietary querying language. It comes with a set of predefined functions that you can use for simple queries such as averages or complex statistical analysis such as skewness and kurtosis.

Before you get started, you should know that:

  • Metrics always return numerical values.
  • Metric can only return value based on some dimensionality/context in which it is executed - more about that in MAQL and Multidimensionality .
  • Metrics in MAQL start with keyword SELECT.
    A simple aggregation function looks like this:
    SELECT SUM({fact/quantity})

Write Your First Metrics

The following examples will show you a simple progression path to building your own metrics. Each example is followed by syntax description.

MAQL always works in the context of data available in a given logical data model which determines the available data and utilization of MAQL statements.

Example 1 - quantity

The following sample uses the SUM aggregation function on a fact (quantity) to return total all-time sales:

SELECT SUM({fact/quantity})

This will result in an insight featuring a single number, total units sold, in a single row.

Example 2 - adding arithmetic

To find out what was the revenue of the total all-time sales, first multiply two facts (quantity and price) and then aggregate to the context:

SELECT SUM({fact/quantity} * {fact/price})

This will result in a insight featuring a single number, revenue for total units sold, in a single row.

Example 3 - conditioning/filtering and reusing metrics

The following example reuses the existing metric (Amount Sold) and combines it with the conditional statement WHERE defined by the Label (Color) and Label Value (Red).

SELECT {metric/amount_sold} WHERE {label/Color}="red"

When constructing complex metrics, your choice of attributes and attribute values is determined by the context of available data.

Add Comments to Custom Metric

You can add comments to your customized metric by including the # symbol.


SELECT {metric/amount_sold} # this is a comment

Anything after the hash sign # is ignored during computation. If you need multiline comments, each line must start with a #.