Microsoft Fabric Updates Blog

Introducing Aggregations in Fabric API for GraphQL: Query Smarter, Not Harder

Summarize, group, and explore data in one step with the new GraphQL aggregations feature

We’re excited to launch a powerful new capability in the Fabric API for GraphQL—Aggregations. This feature brings native support for summary-level insights directly into your GraphQL queries, making your data exploration faster, simpler, and more efficient.

Why Aggregations?

Until now, getting summary metrics like totals, averages, or counts required workarounds—either writing custom logic or running multiple queries and doing the math client-side. Aggregations change that.

Now you can:

  • Query KPIs and summary values directly from your API.
  • Use filtering, slicing, and grouping with the new group by argument.
  • Build dashboards and apps that load faster with fewer queries.

The new aggregation operations include:

  • count – Count of records (or non-null values of a field) in the group.
  • sum – Sum of all values in a numeric field.
  • avg – Average (mean) of values in a numeric field.
  • min – Minimum value in a field.
  • max – Maximum value in a field.

How It Works

With Aggregations, you can use the new groupBy argument on a queryable field to group data and apply functions like sum, avg, and count in a single query.

Example 1: Total Products by Category

query {
  products {
   groupBy(fields: [category_id]) 
   {
      fields {
         category_id # grouped key values
      }
      aggregations {
        count(field: id) # count of products in each group (count of "id")
     } 
   }
  }
}

This returns aggregated results grouped by category, similar to what you might see in a pivot table.

{
  "data": {
    "products": {
      "groupBy": [
        {
          "fields": {
            "category_id": 1
          },
          "aggregations": {
            "count": 3
          }
        },
        {
          "fields": {
            "category_id": 2
          },
          "aggregations": {
            "count": 2
          }
        },
      ...
      ]
    }
  }
}

Example 2: Calculate sum of prices and average ratings

query {
  products {
   groupBy(fields: [category_id]) 
   {
      fields {
         category_id
      }
     aggregations {
        count(field: id)   # number of products in the category
        sum(field: price)  # total of all product prices in the category
        avg(field: rating) # average rating of products in the category
     } 
   }
  }
}

In addition to counting, you can also calculate sums and averages for different fields group by product categories:

{
  "data": {
    "products": {
      "groupBy": [
        {
          "fields": {
            "category_id": 1
          },
          "aggregations": {
            "count": 3,
            "sum": 2058.98,
            "avg": 4
          }
        },
        {
          "fields": {
            "category_id": 2
          },
          "aggregations": {
            "count": 2,
            "sum": 109.94,
            "avg": 4
          }
        },
        ...
      ]
    }
  }
}

Built for Simplicity and Scale

Just like the rest of Fabric API for GraphQL, Aggregations are strongly typed and schema-aware. You get discoverable field names and backend query optimizations — all with the flexibility of GraphQL.

Try It Today

Aggregations are available now for supported data sources via Fabric API for GraphQL. You can find more information about Fabric GraphQL Aggregations, including additional examples, in our documentation.

Ready to summarize your data faster? Give the aggregations feature a try and let us know what you think! Submit your feedback to Fabric Ideas.

Related blog posts

Introducing Aggregations in Fabric API for GraphQL: Query Smarter, Not Harder

December 18, 2025 by Jovan Popovic

Unlock Flexible Time-Based Reporting with DATE_BUCKET() in Microsoft Fabric DW! Microsoft Fabric Data Warehouse continues to evolve with powerful features that make analytics easier and more adaptable. One of the latest additions is the DATE_BUCKET() function—a game-changer for time-based reporting.

December 18, 2025 by Anna Hoffman

What a year 2025 has been for SQL! ICYMI and are looking for some hype, might I recommend you start with this blog from Priya Sathy, the product leader for all of SQL at Microsoft: One consistent SQL: The launchpad from legacy to innovation. In this blog post, Priya explains how we have developed and … Continue reading “2025 Year in Review: What’s new across SQL Server, Azure SQL and SQL database in Fabric”