AQL Expression is the next-gen upgrade to our current Business Calculation mechanism, designed to give you a more powerful and flexible way of querying data for various analytics purposes, including but not limited to:
- Cross-model Calculation - Perform calculations across multiple models without having to manually merge the data via SQL Model.
- Nested Aggregation - Create more complex calculations by nesting functions and aggregations within each other.
- Add Filtering in an AQL Expression - Filter your data at the query level rather than having to do it in a separate step.
- Support Date/Time Intelligence Functions - Analyze your data over time using powerful date/time intelligence functions.
- Subgroup Calculation - Perform calculations on subgroups of your data without having to create a separate query for each subgroup.
01. Cross-model Calculation
Let’s say you are a Country Manager of an Ecommerce Company and you want to calculate the Revenue by Country.
The formula to calculate it is the sum of the product price (from the Product model) multiplied by the quantity (from the Order Items model).
They are from 2 different models so you can write an AQL expression like the video below
Sample syntax
sum(order_items.quantity) * 1.0 /
eval(sum(order_items.quantity),exclude(users.age_group))
02. Sub-group Calculation
With AQL Expression, you can perform Subgroup Calculations flexibly and easily without having to create SQL (or transform) Models.
Here's the sample syntax:
sum(order_items.quantity) * 1.0 /
eval(sum(order_items.quantity), exclude(users.age_group))
Learn more here: [Upcoming] Our brand new Analytics Query Language, AQL!