PREP WITH PROOF
Menu
MICROSOFT FABRIC / PRACTICAL GUIDE

Fabric Warehouse SQL GROUP BY: Monthly Revenue for DP-600

Use DATETRUNC, GROUP BY, and SUM in Fabric Warehouse to calculate monthly revenue by region and category. Check results with a six-row DP-600 lab.

THE QUICK ANSWER

In Fabric Warehouse, use DATETRUNC(month, SaleDate) to derive a month-start date, then GROUP BY that date, Region, and ProductCategory. Apply SUM(Revenue) to return one row for each combination present in the data. Grouping by the month number alone would combine the same month across different years.

Run a monthly revenue query on six rows

Imagine a controller asks for a result a downstream report can consume directly. Each input row is an order line. Each output row should represent one calendar month, one region, and one product category. The fixture includes two years, two November order lines for one group, and a December boundary row. Run the whole statement in a Fabric Warehouse query window.

The first CTE is a stand-in for a fact table. In a real query, replace sales in the second CTE with your table name. Compute MonthStart there so the outer SELECT and GROUP BY can both use it. Apply the half-open date filter to SaleDate before grouping. This includes November 30 and excludes December 1 for the specified reporting range.

WITH sales AS (
    SELECT CAST('2025-11-30' AS date) AS SaleDate,
           'North' AS Region, 'Tools' AS ProductCategory, 90 AS Revenue
    UNION ALL SELECT CAST('2026-11-01' AS date), 'North', 'Tools', 110
    UNION ALL SELECT CAST('2026-11-13' AS date), 'North', 'Tools', 40
    UNION ALL SELECT CAST('2026-11-30' AS date), 'North', 'Supplies', 60
    UNION ALL SELECT CAST('2026-11-30' AS date), 'South', 'Tools', 70
    UNION ALL SELECT CAST('2026-12-01' AS date), 'North', 'Tools', 200
),
at_month AS (
    SELECT DATETRUNC(month, SaleDate) AS MonthStart,
           Region, ProductCategory, Revenue
    FROM sales
    WHERE SaleDate >= CAST('2025-11-01' AS date)
      AND SaleDate <  CAST('2026-12-01' AS date)
)
SELECT MonthStart, Region, ProductCategory, SUM(Revenue) AS MonthlyRevenue
FROM at_month
GROUP BY MonthStart, Region, ProductCategory
ORDER BY MonthStart, Region, ProductCategory;

Source: Microsoft Learn — DATETRUNC (Transact-SQL) ↗

Check the result and the reporting grain

You should get the four rows below. The North Tools rows in November 2026 combine to 150. The North Tools row from November 2025 stays separate. North Supplies and South Tools stay separate because their category or region differs. The four totals add to 370, which you can reconcile to the source after the same date filter.

An absent month–region–category combination produces no row in this query. If the report needs explicit zeroes, first define which combinations should exist, typically using calendar and dimension tables. Join the aggregates to that set and decide how to display missing results. Avoid inventing combinations without a reporting requirement.

MonthStartRegionProductCategoryMonthlyRevenue
2025-11-01NorthTools90
2026-11-01NorthSupplies60
2026-11-01NorthTools150
2026-11-01SouthTools70

Source: Microsoft Learn — Analytical and aggregate functions in Fabric ↗

Spot query shapes that change the answer

If you omit ProductCategory, North in November 2026 becomes one total of 210. If you use MONTH(SaleDate) as the entire period key, North Tools from both years becomes 240 for month 11. Both queries run, but their rows mean something different. If you use SUM(Revenue) OVER (PARTITION BY ...), the window calculation annotates each underlying row. The two North Tools order lines in 2026 would each show 150. Use a grouped aggregate when the output itself must be one row per group.

If a production query joins dimensions before grouping, compare the filtered row count and revenue before and after the joins. An unintended one-to-many match can repeat a fact row and inflate revenue even with the right GROUP BY columns. Investigate the join keys before changing the aggregate.

Source: Microsoft Learn — Analytical and aggregate functions in Fabric ↗

Apply the same grain decision in the DP-600 sample

In an exam scenario, write down what one output row represents first. If the request is for a relational result at a lower grain than the source, look for a GROUP BY that includes every requested dimension and an aggregate on the numeric fact. A filter controls which rows contribute. It cannot collapse rows into the requested grain on its own.

Open the free DP-600 sample below in Study mode and look for the Warehouse question about monthly revenue. Name all three grouping keys before you choose an answer, then check the explanation.

Source: Microsoft Learn — DP-600 study guide ↗

KEEP THESE THREE THINGS

Your next steps

  1. Use a year-aware month key.
  2. Group by each attribute that defines one result row.
  3. Reconcile the grouped total to the date-filtered facts.

Sources & official resources

Linked resources checked on 2026-11-28. Technical behavior and provider guidance can change; check the documentation for the version you use.

About this guide and its recommendations

Published by Prep With Proof with AI-assisted drafting. Study routines and examples are editorial suggestions, not official exam instructions or claims of a learner's personal results. Cited provider facts are linked; ownership of recommended Prep With Proof products is disclosed. No competitor endorsement or guaranteed certification outcome is implied.

Suggest a correction →