On this page
Aggregates reference
Look up counts, sums and transaction totals.
Before you begin: Selectors and aggregates reference.
Aggregates
Aggregates are exposed as special path segments.
| Syntax | Result |
|---|---|
$transactions.{$where: {status:'successful'}}.$count | Count matching current-user transactions. |
$transactions.{$where: {status:'successful'}}.$sum.requestedAmount | Sum requestedAmount on matching current-user transactions. |
$posts.investments.{$where: {status:'active'}}.$count | Count matching posts. |
$posts.investments.{$where: {status:'active'}}.$sum.amount | Sum the amount field on matching posts. |
For post fields declared as money in FRL, sums use the active site currency. Ordinary number fields continue to return numeric totals.
For sums, the field is written after $sum:
Function calls are written as path segments. The resolved value before .functionName() is passed to the browser function:
Frontbacked returns the aggregate first, then passes that value to the registered function. Function arguments are supported, but the aggregate field still belongs after $sum: $sum.requestedAmount.formatMoney('USD'), not $sum(requestedAmount).
Older themes may still use $counts, but new FQL should use $count.
When summing paidAmount, filter by paidCurrency or another single-method condition to avoid summing mixed units:
Transaction rows expose the stored status. Completed payments currently appear as successful in FQL transaction filters and rows. FRL payment events expose the same completion event as payment confirmed with $payment.status == "confirmed" and $payment.rawStatus available for compatibility.
Continue with HTML attributes reference.