Forum Discussion
Anonymous
5 years agoNot applicable
Basket Type analysis
Hi All, I have the following Sales Order Table: Line_Item_ID Sales_Order_ID SKU 1 1 4 2 1 1 3 2 4 4 3 1 5 3 7 6 3 4 7 4 4 8 5 1 9 5 8 ...
- Anonymous5 years ago
Hi Anonymous
Here I have two ways to get the average.
Calculated column:
Avg = VAR _CountOrder = CALCULATE ( DISTINCTCOUNT ( 'Table'[Sales_Order_ID] ), FILTER ( 'Table', 'Table'[SKU] = EARLIER ( 'Table'[SKU] ) ) ) VAR _OrderT = SUMMARIZE ( FILTER ( 'Table', 'Table'[SKU] = EARLIER ( 'Table'[SKU] ) ), 'Table'[Sales_Order_ID] ) VAR _CountItem = CALCULATE ( COUNT ( 'Table'[Line_Item_ID] ), FILTER ( 'Table', 'Table'[Sales_Order_ID] IN _OrderT ) ) RETURN _CountItem / _CountOrderResult is as below.
Measure:
M_Avg = VAR _CountOrder = CALCULATE ( DISTINCTCOUNT ( 'Table'[Sales_Order_ID] ), FILTER ( ALL('Table'), 'Table'[SKU] = MAX('Table'[SKU] ) ) ) VAR _OrderT = SUMMARIZE ( FILTER (ALL( 'Table'), 'Table'[SKU] = MAX ( 'Table'[SKU] ) ), 'Table'[Sales_Order_ID] ) VAR _CountItem = CALCULATE ( COUNT ( 'Table'[Line_Item_ID] ), FILTER ( ALL('Table'), 'Table'[Sales_Order_ID] IN _OrderT ) ) RETURN _CountItem / _CountOrderResult is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
5 years agoNot applicable
Hi Anonymous
Here I have two ways to get the average.
Calculated column:
Avg =
VAR _CountOrder =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Sales_Order_ID] ),
FILTER ( 'Table', 'Table'[SKU] = EARLIER ( 'Table'[SKU] ) )
)
VAR _OrderT =
SUMMARIZE (
FILTER ( 'Table', 'Table'[SKU] = EARLIER ( 'Table'[SKU] ) ),
'Table'[Sales_Order_ID]
)
VAR _CountItem =
CALCULATE (
COUNT ( 'Table'[Line_Item_ID] ),
FILTER ( 'Table', 'Table'[Sales_Order_ID] IN _OrderT )
)
RETURN
_CountItem / _CountOrder
Result is as below.
Measure:
M_Avg =
VAR _CountOrder =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Sales_Order_ID] ),
FILTER ( ALL('Table'), 'Table'[SKU] = MAX('Table'[SKU] ) )
)
VAR _OrderT =
SUMMARIZE (
FILTER (ALL( 'Table'), 'Table'[SKU] = MAX ( 'Table'[SKU] ) ),
'Table'[Sales_Order_ID]
)
VAR _CountItem =
CALCULATE (
COUNT ( 'Table'[Line_Item_ID] ),
FILTER ( ALL('Table'), 'Table'[Sales_Order_ID] IN _OrderT )
)
RETURN
_CountItem / _CountOrder
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
5 years agoNot applicable
Thanks so much - I see the intermediate steps that is what I needed.