Quick answer
Correct source rows do not guarantee correct Power BI totals. Relationships determine which rows a visual includes, and measures determine how those rows are calculated. Start by checking the fact-table grain, dimension-key uniqueness, active relationships and filter direction. Then reconcile a simple sales measure to the source before troubleshooting more complex calculations. (learn.microsoft.com)
This tutorial uses a small, synthetic dataset, not actual business results. You need Power BI Desktop and basic familiarity with importing tables. The example uses Import mode and DAX, Power BI’s formula language; no SQL is required.
Menu placement can vary between Desktop releases. Follow the named model properties rather than relying on a particular screen layout.
1. Define exactly what one sales row represents
The grain is the meaning of one row. Write it down before creating relationships.
For this example:
One row in
Salesrepresents one sales-order line for one product on one order date.
A fact table stores events or observations and the numeric values you summarize. Dimensions describe the entities used to filter and group those facts. Keep the fact table at a consistent grain. (learn.microsoft.com)
Create a table named Sales using Enter data, or import these values from a spreadsheet:
| SalesLineID | OrderID | OrderDate | ProductKey | Quantity | UnitPrice | SalesAmount |
|---|---|---|---|---|---|---|
| L1 | O100 | 2026-01-01 | 1 | 2 | 50 | 100 |
| L2 | O100 | 2026-01-01 | 2 | 1 | 60 | 60 |
| L3 | O101 | 2026-01-02 | 1 | 1 | 50 | 50 |
| L4 | O102 | 2026-01-02 | 2 | 2 | 40 | 80 |
Set both keys and Quantity to Whole number, OrderDate to Date, and monetary columns to Fixed decimal number.
The fixture’s control values are:
- Sales lines: 4
- Distinct orders: 3
- Quantity: 6
- Sales amount: 290
Notice that order O100 has two lines. Counting rows answers “How many sales lines?”—not “How many orders?”
For this exercise, SalesAmount equals quantity multiplied by unit price. Taxes, shipping, discounts, returns and multiple currencies are outside the example.
2. Prepare product and date dimensions
Create Product with one row per product:
| ProductKey | ProductName | Category |
|---|---|---|
| 1 | Notebook | Stationery |
| 2 | Desk lamp | Furniture |
Here, ProductKey identifies a product; the other columns provide readable labels for report grouping.
Create a calculated table using New table:
Date =
CALENDAR(
DATE(2026, 1, 1),
DATE(2026, 12, 31)
)
CALENDAR returns a single Date column containing every date between the endpoints, including both endpoints. (learn.microsoft.com)
This full-year table also follows Microsoft’s date-table guidance: unique dates, no blanks, no missing dates and coverage of complete years. For classic time-intelligence functions, mark it as a date table using its Date column. Calendar-based time intelligence has different marking requirements; this tutorial does not use either system’s time calculations. (learn.microsoft.com)
Keep the three tables separate. Use Product and Date fields for slicers and grouping, and Sales values for calculations.
3. Build active, one-to-many relationships
In Model view, create or inspect these relationships:
| Dimension column | Fact column | Cardinality | Cross-filter direction |
|---|---|---|---|
Product[ProductKey] |
Sales[ProductKey] |
One-to-many, 1:* |
Single |
Date[Date] |
Sales[OrderDate] |
One-to-many, 1:* |
Single |
Both relationships should be active.
Cardinality describes whether the related columns contain unique or repeated values. The dimension is the unique “one” side; sales can repeat the same product or date on the “many” side. Single-direction filtering propagates from the dimension to sales. (learn.microsoft.com)
Do not assume automatically detected relationships are correct. Confirm the selected columns, cardinality, active status and arrow direction. An active relationship appears as a solid line. (learn.microsoft.com)
Leave cross-filter direction as Single for this example. Setting every relationship to Both is not a general repair strategy. Microsoft recommends minimizing bidirectional relationships because they can increase query work and create confusing filtering behavior. (learn.microsoft.com)
Also check dates at import. A timestamp merely displayed as a date can retain its time component and fail to match a date dimension. Remove the time component in Power Query when the intended key is a calendar date. (learn.microsoft.com)
4. Create simple measures and establish a baseline
Create these measures individually using New measure:
Sales Amount =
SUMX(Sales, Sales[SalesAmount])
Sales Lines =
COUNTROWS(Sales)
Orders =
DISTINCTCOUNT(Sales[OrderID])
SUMX evaluates an expression for each row and sums the results. Here it simply adds the stored sales amounts. COUNTROWS counts table rows, while DISTINCTCOUNT counts unique column values. (learn.microsoft.com)
On a clean report page, add cards for the three measures. With no filters applied, their expected values are 290, 4 and 3.
Next, create a matrix using Product[Category] as rows and [Sales Amount] as values:
| Category | Expected sales amount |
|---|---|
| Furniture | 140 |
| Stationery | 150 |
| Total | 290 |
Add a slicer using Date[Date]. January 1 should return 160; January 2 should return 130.
These are expected results calculated from the supplied fixture, not claims about a tested production report.
A measure responds to its filter context: the values allowed by slicers, report filters, visual headings and formula logic. The category row and date slicer therefore change which sales contribute to the calculation. (learn.microsoft.com)
5. Diagnose a duplicate product key without hiding it
Now consider this deliberately faulty replacement for Product:
| ProductKey | ProductName | Category |
|---|---|---|
| 1 | Notebook | Stationery |
| 1 | Notebook | Gifts |
| 2 | Desk lamp | Furniture |
Product key 1 now appears twice, with conflicting categories.
In this Import-mode example, these values cannot form the unique side of the intended relationship. If a refresh tries to load duplicate values into an existing “one” side, Power BI fails the refresh. (learn.microsoft.com)
Inspect the full product query: group by ProductKey, count rows in each group, and investigate every count above one. For this faulty fixture, key 1 has two rows.
Do not switch to many-to-many merely to make the relationship acceptable. That changes the model’s meaning.
For illustration, suppose you deliberately create an active many-to-many relationship filtering from this faulty product table to sales. With the simple sales measure, both category filters select product key 1:
| Category | Expected sales amount |
|---|---|
| Furniture | 140 |
| Gifts | 150 |
| Stationery | 150 |
| Grand total | 290 |
The displayed category values add to 440, but the grand total remains 290. This is a deduction from the fixture and filter behavior: the two categories overlap, while the total evaluates the underlying sales once in its broader context. (learn.microsoft.com)
There is another route to 440. If you left-merge sales with the faulty product table and expand the matching product records, each key-1 sales line receives two matches. The resulting fixture has six rows and repeated sales amounts. Power Query merges and expands matching records; this is different from merely creating a model relationship. (learn.microsoft.com)
6. Correct the key according to its business meaning
For the teaching fixture, the canonical category for key 1 is explicitly Stationery. Remove the erroneous Gifts row, restore Product to two rows, and return the relationship to active 1:*, Single.
For real data, the correct category is unknown until you establish an authoritative rule. Do not keep an arbitrary row simply because it makes the key unique.
Choose the correction based on what the repeated key represents:
- Accidental duplicates: investigate ingestion or transformation steps, then retain one authoritative product record.
- Different entities sharing a code: create a genuinely unique identifier and map each sales row to the correct entity.
- Historical product versions: use unique version keys and assign sales to the appropriate version. A surrogate key alone does not decide which version a sale belongs to. (learn.microsoft.com)
- Products intentionally belonging to several categories: model the associations with a bridge table. Define whether sales should appear in every applicable category or be allocated between categories; those are different reporting questions. Microsoft’s many-to-many guidance uses bridging tables for dimension associations. (learn.microsoft.com)
A repair is safe only when it preserves the intended grain and classification—not merely when the error message disappears.
7. Distinguish incorrect totals from non-additive measures
Some totals should not equal the sum of displayed rows.
Using the corrected model, [Orders] returns:
| Category | Distinct orders |
|---|---|
| Furniture | 2 |
| Stationery | 2 |
| Total | 3 |
Order O100 contains both products. It is counted once within each category but only once across the whole dataset. Distinct counts are therefore non-additive. Replacing them with row counts would answer a different question. (learn.microsoft.com)
Ratios also need an explicit definition. For example:
Quantity =
SUMX(Sales, Sales[Quantity])
Revenue per Unit =
DIVIDE([Sales Amount], [Quantity])
DIVIDE performs division and returns blank on division by zero unless you specify an alternate result. (learn.microsoft.com)
The fixture’s overall revenue per unit is 290 ÷ 6 = 48.33, rounded to two decimals. Furniture is 140 ÷ 3 = 46.67, and Stationery is 150 ÷ 3 = 50.00. Adding those category ratios would not answer the overall question.
Before changing DAX, write the intended total in plain language: “Count unique orders” or “Divide total revenue by total units.”
8. Reconcile the model before trusting the dashboard
Use this order of checks:
- Match the comparison scope. Use the same date range and business definition for source and report.
- Check the loaded fact rows. Confirm the expected line count, distinct orders, quantity and sales amount.
- Inspect transformation changes. Compare counts and amounts before and after any merge or expansion.
- Check dimension keys. Investigate duplicates, blanks and sales keys missing from dimensions.
- Test filter propagation. Select one known product and one known date, then compare the result with the corresponding source lines.
- Inspect the visual and measure. Check visual filters, aggregation choices and calculation logic.
Microsoft’s troubleshooting guidance identifies missing relationships, incorrect columns, unexpected filters, stale data and measure logic as possible causes of incorrect results. Unmatched fact keys can also produce blank dimension groupings in regular relationships. (learn.microsoft.com)
For this fixture, stop only when the unfiltered controls return 4 lines, 3 orders, 6 units and 290 sales, and both category and date tests agree.
Keep a short model note recording the grain, key definitions, classification rules and expected controls. A matching grand total is necessary—but it is not sufficient evidence that every breakdown is correct.