Forum Discussion

Derekp978's avatar
Derekp978
Frequent Visitor
6 years ago
Solved

Calculate Transactions Per Order

All - I have a simple data set that looks like the following - and we are looking for Avg Transactions Per Order (For all orders that remain unfiltered completely)   Order ID Transaction ID Tr...
  • Anonymous's avatar
    Anonymous
    6 years ago
    // (ABS) means "absolute", so
    // that you know filters do not
    // affect this number.
    [Avg Tx Per Order (ABS)] =
    var __txCount = 
    	CALCULATE(
    		// Since the table T has a
    		// unique column of transactions...
    		COUNTROWS( T ),
    		VALUES( T[OrderID] ),
    		ALL( T )
    	)
    var __orderCount =
    	DISTINCTCOUNT( T[OrderID] )
    var __result =
    	DIVIDE(
    		__txCount,
    		__orderCount
    	)
    return
    	__result