# Power BI measure definitions

These DAX measures respect report filter context. Currency is GBP for retail; demand errors are rentals per observed hour. DAX has not been evaluated by a local Power BI engine.

## Gross Sales

Positive-priced, positive-quantity, non-cancellation invoice sales.

```dax
Gross Sales =
SUM ( FactLedger[GrossSales] )
```

Format: `£#,0.00`

## Credits

Magnitude of negative-quantity, positive-priced lines; not matched returns.

```dax
Credits =
SUM ( FactLedger[Credits] )
```

Format: `£#,0.00`

## Net Invoiced Value

Signed positive-priced ledger value; not profit.

```dax
Net Invoiced Value =
SUM ( FactLedger[NetValue] )
```

Format: `£#,0.00`

## Sales Orders

Distinct invoices containing eligible gross sales, in the current filter context.

```dax
Sales Orders =
CALCULATE ( DISTINCTCOUNT ( FactLedger[InvoiceKey] ), FactLedger[IsSale] = 1 )
```

Format: `#,0`

## Average Order Value

Gross sales divided by distinct eligible invoices.

```dax
Average Order Value =
DIVIDE ( [Gross Sales], [Sales Orders] )
```

Format: `£#,0.00`

## Credit Value Ratio

Credits relative to gross invoiced sales; not a return rate.

```dax
Credit Value Ratio =
DIVIDE ( [Credits], [Gross Sales] )
```

Format: `0.0%`

## Source Lines

All source lines are preserved, including nonpositive prices.

```dax
Source Lines =
COUNTROWS ( FactLedger )
```

Format: `#,0`

## Missing Customer Lines

Lines with no original customer identifier.

```dax
Missing Customer Lines =
SUM ( FactLedger[MissingCustomer] )
```

Format: `#,0`

## Missing Customer Share

Share of invoice lines without an identified customer.

```dax
Missing Customer Share =
DIVIDE ( [Missing Customer Lines], [Source Lines] )
```

Format: `0.0%`

## Nonpositive Price Lines

Rows excluded from priced ledger and gross sales due to nonpositive unit price.

```dax
Nonpositive Price Lines =
SUM ( FactLedger[NonPositivePrice] )
```

Format: `#,0`

## Ledger Reconciliation

Must be zero for these source data; positive cancellation anomalies would be surfaced.

```dax
Ledger Reconciliation =
[Gross Sales] - [Credits] - [Net Invoiced Value]
```

Format: `£#,0.00`

## Identified Customers

Identified customers with eligible sales in the selected observation window.

```dax
Identified Customers =
CALCULATE ( DISTINCTCOUNT ( FactLedger[CustomerKey] ), FactLedger[IsSale] = 1, FactLedger[CustomerKey] <> 0 )
```

Format: `#,0`

## Identified Sales

Gross sales from customers whose source identifier is present.

```dax
Identified Sales =
CALCULATE ( [Gross Sales], FactLedger[CustomerKey] <> 0 )
```

Format: `£#,0.00`

## Identified Sales Coverage

The fraction of gross sales covered by customer-level analysis.

```dax
Identified Sales Coverage =
DIVIDE ( [Identified Sales], [Gross Sales] )
```

Format: `0.0%`

## Repeat Buyers

Identified customers with more than one eligible invoice in the current window.

```dax
Repeat Buyers =
VAR Eligible = FILTER ( VALUES ( FactLedger[CustomerKey] ), FactLedger[CustomerKey] <> 0 && CALCULATE ( [Sales Orders] ) > 0 ) RETURN COUNTROWS ( FILTER ( Eligible, CALCULATE ( [Sales Orders] ) > 1 ) )
```

Format: `#,0`

## Repeat Buyer Share

Depends on selected observation window and tenure; not fixed-horizon retention.

```dax
Repeat Buyer Share =
DIVIDE ( [Repeat Buyers], [Identified Customers] )
```

Format: `0.0%`

## Sales Units

Positive units on eligible gross-sales lines.

```dax
Sales Units =
SUM ( FactLedger[SalesUnits] )
```

Format: `#,0`
