Building BI reports
How to design, build and deliver Business Intelligence (BI) reports: objectives, key concepts (datasets, grouping, filtering, aggregations, drill-through, scheduling), example SQL/DAX expressions, step-by-step examples, common exam mistakes and short questions.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
BI reports let engineers and business users turn data into decisions. A well-built BI report (a formatted presentation of data, often with charts and tables) gives accurate, timely answers to questions such as sales by region, trend vs target, and which customers to contact. Engineers build reports to ensure correctness, performance and repeatable delivery to stakeholders.
Key ideas
Start with definitions (each term defined once, in bold):
- BI report: a reusable document or view that presents data (tables, charts, KPIs) for analysis or decision-making. It is often generated from a dataset and may include parameters, filters and visual layout.
- Dataset: a structured collection of data rows and columns (for example, a SQL query result or a table in a data warehouse) used as a source for a report.
- Aggregation: a computation that summarizes multiple rows into a single value (examples: sum, count, average, min, max). Aggregation requires a grouping context or window to define which rows are summarized.
- Grouping: the act of combining rows that share the same value in one or more columns so aggregations are computed per group (in SQL: GROUP BY).
- Filtering: selecting a subset of rows from the dataset using boolean conditions (in SQL: WHERE for row-level filtering, HAVING for group-level filtering).
- Expression: a computed value defined in the report using available columns, constants, functions and operators (often implemented as SQL expressions, DAX measures, or report tool calculated fields).
- Drill-through: a navigation feature where a user clicks a value (for example a region) to see a more detailed report or raw rows that explain that value.
- Parameter: a named input to a report used to change filters, date ranges, or other aspects at runtime.
- Scheduling: automation of report generation and delivery (email, file drop) at specified times.
- ETL: Extract, Transform, Load — the process that prepares and moves data from sources to the dataset or data warehouse used by reports.
- KPI: Key Performance Indicator — a single numeric metric with a defined target and thresholds used to evaluate performance.
Design principles and assumptions:
- Correctness: aggregations must use the correct grouping context. Assumption: the dataset contains consistent keys (e.g., product_id) and timestamps when needed. Also verify join cardinalities/grain to avoid double-counting when joining facts to one-to-many dimensions; prefer a star schema and keep measures at a single, well-defined grain.
- Performance: reports should push heavy aggregation to the database (use GROUP BY, indexes, pre-aggregations) rather than computing row-by-row in the report rendering engine.
- Freshness: scheduling must match business needs and source data update frequency.
- Security and governance: report access must respect data permissions; sensitive columns should be masked or omitted.
Exact statements and commonly required derivations (exam style):
SQL grouping rule: When using GROUP BY, every selected column must either be listed in GROUP BY or be an aggregate of grouped rows. If a SELECT contains non-aggregated columns not in GROUP BY, SQL will error (standard SQL) or give indeterminate results (some dialects allow nonstandard behavior). Draw: a table with columns A,B,C; show grouping by A and SUM(C) and explain why B cannot appear unaggregated. Also recall NULL semantics of aggregates: SUM/AVG ignore NULLs; COUNT(*) counts all rows; COUNT(col) counts only non-NULL values in col; COUNT(DISTINCT col) counts distinct non-NULL values and may be more expensive.
Distinction WHERE vs HAVING: Draw two-step diagram of query evaluation order: FROM/JOIN -> WHERE -> GROUP BY -> HAVING -> SELECT -> ORDER BY. Label each step and explain WHERE filters rows before grouping; HAVING filters groups after aggregation.
Running total derivation using window functions: Explain that a running total over ordered rows uses SUM(value) OVER (PARTITION BY key ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW). Show how this equals incremental cumulative sums.
Drill-through semantics: Describe a parent-child navigation: primary report shows aggregated rows; clicking a cell passes parameter values to a secondary report that runs a query with WHERE equal to those parameter values and returns raw rows.
Formulas
(For report-building, list important SQL / DAX syntax lines to remember.)
SELECT col1, SUM(col2) AS total FROM table WHERE <condition> GROUP BY col1; — col1: grouping column, col2: numeric column, applies for grouped aggregation.
SELECT col, SUM(value) OVER (PARTITION BY col2 ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS running_total FROM table; — running_total: cumulative sum; ORDER BY defines time order.
SELECT col1, COUNT(*) AS cnt FROM table WHERE <condition> GROUP BY col1 HAVING COUNT(*) > 10; — HAVING filters groups after aggregation.
-- DAX measure (Power BI): Total Sales = SUM(Sales[SalesAmount]) — defines a measure named Total Sales summing SalesAmount column in Sales table.
-- DAX for year-over-year growth: YoY % = DIVIDE([Total Sales] - CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Date[Date])), CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Date[Date]))) — DIVIDE avoids divide-by-zero; SAMEPERIODLASTYEAR shifts context by one year.
-- Parameterized report (pseudo): -- For DATE columns, BETWEEN is fine; for DATETIME, prefer a half-open interval to avoid end-of-day time issues: -- WHERE OrderDate >= @StartDate AND OrderDate < DATEADD(day, 1, @EndDate) SELECT * FROM Sales WHERE OrderDate BETWEEN @StartDate AND @EndDate; — @StartDate and @EndDate are runtime parameters.
-- Schedule (cron example): 0 6 * * MON /path/to/run_report.sh — run every Monday at 06:00; exact cron format varies by system.
For each syntax line above: col names are database column identifiers; functions like SUM, COUNT, DIVIDE are standard aggregates or extensions in the tool. Use the dialect your exam expects (SQL standard, T-SQL, or DAX).
Worked examples
Example 1 — Sales by Region (numerical + SQL): Data: Sales table with columns: Region (text), OrderDate (date), Amount (₹). Compute total sales per region for March 2026, ordered by total descending.
Steps:
- Filter rows in March 2026:
WHERE OrderDate >= '2026-03-01' AND OrderDate < '2026-04-01'. - Group by Region and sum Amount:
SELECT Region, SUM(Amount) AS TotalSalesthenGROUP BY Region. - Order descending:
ORDER BY TotalSales DESC.
SQL shown:
SELECT Region, SUM(Amount) AS TotalSales FROM Sales WHERE OrderDate >= '2026-03-01' AND OrderDate < '2026-04-01' GROUP BY Region ORDER BY TotalSales DESC;
Assume sample rows: (North, 1000), (South, 1500), (North, 2000). Calculation: North total = 1000+2000 = 3000 ₹; South = 1500 ₹. Final answer: North: ₹3000, South: ₹1500.
Example 2 — Running total and percent contribution (trace): Data sorted by Date for product P: day1 ₹100, day2 ₹150, day3 ₹250.
Running total at day3 = 100+150+250 = 500 ₹. Percent contribution of day3 = 250 / 500 = 0.5 => 50%.
SQL using window function:
SELECT Date, Amount, SUM(Amount) OVER (ORDER BY Date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS RunningTotal, Amount * 1.0 / SUM(Amount) OVER () AS PercentOfTotal FROM Sales WHERE Product = 'P' ORDER BY Date;
Example 3 — Report design question (model answer): Question: Design a monthly KPI report for Sales Manager including Total Sales, YoY growth, Top 5 products, and drill-through to orders.
Model answer (points to include for full marks):
- Data sources: Sales fact table (order_id, date, product_id, amount), Product dimension, Date dimension.
- Measures: Total Sales = SUM(Amount); YoY % (DAX formula shown in Formulas). Explain date table and continuous date range requirement.
- Layout: top row with KPI cards (Total Sales, YoY % with green/red thresholds), left pane Top 5 products bar chart, right table with region breakdown. Provide drill-through from product bar to detailed orders filtered by product_id.
- Scheduling: run monthly at 02:00 on 1st day; distribute PDF by email to Sales Manager.
- Security: Row-level security by region.
Common mistakes
- Doing heavy row-level transformations in the report renderer instead of in the database — slow reports.
- Not using a calendar/date dimension for time intelligence (YoY, MTD) — incorrect period calculations.
- Not handling NULLs or divide-by-zero in computed expressions — runtime errors or NaN.
- Hardcoding dates or credentials in scheduled jobs — leads to maintenance and security problems.
- Confusing drill-down (hierarchical expansion inside same report) with drill-through (open a different report). Examiners often ask to define the difference.
For your exam
Question types you will see:
- Definitions (define BI report, dataset, drill-through) — give short precise definitions and one-line examples.
- Short notes (report design, scheduling, parameters) — list components and reasons.
- Derivations / diagrams (show SQL query evaluation order, draw report pipeline) — draw boxes labeled: Source DB -> ETL -> Data Warehouse -> Dataset -> Report Renderer -> Delivery (email/schedule)
- Numericals (aggregate computations, running totals) — show step-by-step calculations with formulas and units (₹, counts).
- Programs / syntax (write SQL / DAX for a measure, parameterized query) — write syntactically correct examples; mention dialect if required.
What a full-marks answer includes:
- Clear definitions of terms asked.
- Correct SQL/DAX syntax or pseudo-code with correct use of GROUP BY / window functions.
- A logical design for the report: data sources, transformations, measures, layout, drill-through and schedule.
- Consideration of performance, security and maintainability.
- Diagrams where asked, with labeled components and arrows showing data flow.
Quick check
- What clause filters groups after aggregation in SQL?
- Name two ways to compute a running total in modern SQL/report tools.
- What is the difference between drill-down and drill-through?
Answers: HAVING; window function SUM(...) OVER (ORDER BY ...) or a self-join/derived table cumulative sum; drill-down expands hierarchy levels inside the same report while drill-through opens a detailed report or dataset filtered on the clicked value.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?