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

June 17, 2025 by Akshay Dixit

The Eventstreams artifact in the Microsoft Fabric Real-Time Intelligence experience lets you bring real-time events into Fabric, transform them, and then route them to various destinations such as Eventhouse, without writing any code (no-code). You can ingest data from an Eventstream to Eventhouse seamlessly either from Eventstream artifact or Eventhouse Get Data Wizard. This capability … Continue reading “Fabric Eventhouse now supports Eventstream Derived Streams in Direct Ingestion mode (Preview)”

June 17, 2025 by Dan Liu

Have you ever found yourself frustrated by inconsistent item creation? Maybe you’ve struggled to select the right workspace or folder when creating a new item or ended up with a cluttered workspace due to accidental item creation. We hear you—and we’re excited to introduce the new item creation experience in Fabric! This update is designed … Continue reading “Introducing new item creation experience in Fabric”