Forum Discussion
Basket Type analysis
- 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.
Hi,
Your question is not clear. How does SKU 1 have the highest number of line items? Please clarify.
- Anonymous5 years agoNot applicable
Sure - the SKU '1' appears in the following Orders:
1, 3 and 5.For those Invoices, there are a total of 7 line items - 7 line items across 3 invoices = 2.3 average line items per invoice where that SKU is bought, where as the SKU of 4 also has 7 line items, but across 4 invoices, giving an average of 1.75 line items per invoice where that SKU is bought.
- Anonymous5 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 / _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.
- Anonymous5 years agoNot applicable
Thanks so much - I see the intermediate steps that is what I needed.