Math and statistics
Choose the denominator and precision explicitly
A mean divides the sum by the number of observations included; a median is the middle sorted value (or the mean of the middle pair). Missing observations should not automatically count as zero sales. Rounding changes a numeric value; display formatting only changes its appearance. Define the statistic, inclusion rule and rounding stage before coding.
Use the isolated Import table ScalarSales from labs/dax-scalar-functions/scalar-sales.csv. In Power Query, explicitly set LineID, Region, ProductCode, ProductName and UnitsText to Text; RevenueUSD to Fixed Decimal Number. Empty RevenueUSD fields must be null, not zero or text. Model culture: en-US; no relationships or RLS. Each row is a synthetic sale-line observation, including two observations with unreported revenue. Currency is USD; no taxes or returns. All results are expected, not native execution evidence. Run each EVALUATE query separately in DAX Query View without report slicers. For a measure or calculated column, create each named definition separately in the appropriate model editor.
Example 1 — Statistics over reported observations
Reuse Reported Revenue if you created it in Lesson 2; otherwise create it now. Create the remaining measures one at a time.
Reported Revenue = SUM(ScalarSales[RevenueUSD])Reported Average = AVERAGE(ScalarSales[RevenueUSD])Reported Median = MEDIAN(ScalarSales[RevenueUSD])Reported Count = COUNT(ScalarSales[RevenueUSD])Missing Count = COUNTROWS(FILTER(ScalarSales, ISBLANK(ScalarSales[RevenueUSD])))Reported Coverage = DIVIDE([Reported Count], COUNTROWS(ScalarSales))With all filters cleared, the reported values are 0, 20, 49, 50, 100. Two other rows are unknown. Total = 219 USD, count = 5, average = 43.8 USD, median = 49 USD, missing count = 2, coverage = 5/7 (about 71.43%). AVERAGE and MEDIAN ignore blank entries in the numeric column but retain actual zeros. North has values 0 and 20 plus one blank, so its average is 10. South has 49, 50 and 100 plus one blank, so its median is 50. For a Missing-only selection, the revenue average and median have no observations and should be shown as BLANK, not 0; COUNT may return BLANK when there are no countable values. Do not infer a zero-sales period from absent data.
Example 2 — Rounding and safe division
EVALUATEROW( "Positive tie", ROUND(2.5, 0), "Negative tie", ROUND(-2.5, 0), "Round each", ROUND(0.125, 2) + ROUND(0.125, 2), "Round sum", ROUND(0.125 + 0.125, 2), "Undefined ratio", DIVIDE(10, 0), "Explicit fallback", DIVIDE(10, 0, 0))Expected values: 3, -3, 0.26, 0.25, BLANK, 0. ROUND uses half-away-from-zero ties. Rounding each transaction and then summing can differ from rounding a total. The correct rule depends on the measurement or accounting contract, not which total looks nicer. These are exact illustrative values, not a general claim about all binary floating-point ties. DIVIDE returns a blank for an undefined ratio by default; the optional constant fallback must be explicitly justified. Formatting a percentage does not require rounding the underlying ratio.
Iterator and population caveats
MEDIANX evaluates an expression for each row and differs from MEDIAN in its treatment of blanks. If the intent is a median of reported row expressions, filter out blank expression results explicitly before invoking MEDIANX. AVERAGEX is useful for a row expression, but an average of equal-weight sale lines is not a per-unit weighted price. For dispersion, distinguish population standard deviation (all members of the defined population) from sample standard deviation (estimate from a sample); do not interpret a tiny synthetic dataset as a statistical inference. Do not substitute blank with zero unless the metric definition explicitly says absence equals zero.
Practice — Reconcile before and after imputation
Calculate the observed average and median from the five reported values. Then intentionally replace both missing values with zero in a separate what-if list. Calculate the new average and median, explain why both change, and decide which is appropriate for the original observation metric. Finally compute coverage and explain why it should be displayed alongside the average.