Divide one distinct count by another to calculate a rate between two types of entities, such as transactions per customer or events per device. COUNTD counts each distinct value once, even when it appears in multiple rows.
Compare order activity across sales channels by calculating orders per active store. Distinct counts prevent orders with multiple order lines from being counted more than once.
Source data: The orders dataset contains one row per order line, with order_id , store_id , and channel columns. Each order belongs to one store. Stores without orders in the selected data are not included.
Formula : COUNTD(order_id) / COUNTD(store_id)
Count orders: COUNTD(order_id) counts each unique order once.
Count active stores: COUNTD(store_id) counts the unique stores represented in the selected data.
Calculate the rate: Divide unique orders by active stores to get orders per active store.
Example result: 120 unique orders across 12 active stores gives 10 orders per active store .
Measure: In a column chart grouped by channel, shows orders per active store for each channel.
Having filter: Keep channels with more than 10 orders per active store using formula > 10 .
npm install @luzmo/nodejs-sdk{
"type": "numeric",
"valid": true
}