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.

Entradas de blog relacionadas

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

julio 17, 2025 por Xu Jiang

We are pleased to announce that Eventstream’s Confluent Cloud for Apache Kafka streaming connector now supports decoding data from Confluent Cloud for Apache Kafka topics that are associated with a data contract in Confluent Schema Registry. The Challenge with Schema Registry Encoded Data The Confluent Schema Registry serves as a centralized service for managing and … Continue reading “Decoding Data with Confluent Schema Registry Support in Eventstream (Preview)”

julio 17, 2025 por Xu Jiang

Introducing multiple-schema inferencing in Eventstream! This feature empowers you to work seamlessly with data sources that emit varying schemas by inferring and managing multiple schemas simultaneously. It eliminates the limitations of single-schema inferencing by enabling more accurate and flexible transformations, preventing field mismatches when switching between Live and Edit modes, and allowing you to view … Continue reading “Enhancing Data Transformation Flexibility with Multiple-Schema Inferencing in Eventstream (Preview)”