# Baseline measures for the DAX lessons

Create the relationships described in README.md first. These formulas target an
Import teaching model. They are review examples, not DAX executed by the Python
fixture verifier. Test in Power BI and record version/context before approval.

```dax
Net Paise =
SUMX(FactSales, FactSales[Quantity] * FactSales[UnitPricePaise] - FactSales[DiscountPaise])

Gross Paise =
SUMX(FactSales, FactSales[Quantity] * FactSales[UnitPricePaise])

Paid Net Paise = CALCULATE([Net Paise], FactSales[Status] = "Paid")
Paid Gross Paise = CALCULATE([Gross Paise], FactSales[Status] = "Paid")
Paid Discount Paise = CALCULATE(SUM(FactSales[DiscountPaise]), FactSales[Status] = "Paid")
Paid Cost Paise = CALCULATE(SUM(FactSales[CostPaise]), FactSales[Status] = "Paid")
Paid Margin Paise = [Paid Net Paise] - [Paid Cost Paise]
Paid Margin Rate = DIVIDE([Paid Margin Paise], [Paid Net Paise])
Paid Discount Rate = DIVIDE([Paid Discount Paise], [Paid Gross Paise])
Paid Orders = CALCULATE(DISTINCTCOUNT(FactSales[OrderID]), FactSales[Status] = "Paid")
Paid Lines = CALCULATE(COUNTROWS(FactSales), FactSales[Status] = "Paid")
Known Paid Customers =
CALCULATE(DISTINCTCOUNT(FactSales[CustomerKey]), FactSales[Status] = "Paid", KEEPFILTERS(FactSales[CustomerKey] <> 0))
```

Each definition is a separate measure. Paid measures deliberately replace a filter
on the same FactSales[Status] column with Paid; they are not selected-status measures.
Use KEEPFILTERS where the intended rule is intersection with the existing status
selection. Other filters, such as dates and product dimensions, remain relevant.

Expected unfiltered controls: Net 77,500; Paid Net 69,500; Paid Gross 72,000;
Paid Discount 2,500; Paid Cost 37,000; Paid Margin 32,500; Paid Orders 6;
Paid Lines 7; Known Paid Customers 3. Paid margin rate = 32,500/69,500;
paid discount rate = 2,500/72,000. Undefined ratios remain BLANK unless a specific
presentation rule justifies a different result.

All amounts are paise. Gross and net are invoice-line values; no revenue-recognition,
tax, refund or profit-accounting policy is implied. Unknown customer key 0 remains
in amount totals but is excluded from Known Paid Customers.
