Forum Discussion
Group then Distinct Count then Average using DAX
- Anonymous3 years ago
Hi RichardJChester ,
Please try:
Avg Shipment Count2 = VAR OrderDates = VALUES ( 'Table'[Ordered On Date] ) VAR Orders = SUMMARIZE ( 'Table', 'Table'[Order Number], 'Table'[Ordered On Date] ) VAR ShipmentsPerOrder = ADDCOLUMNS ( Orders, "Shipments", CALCULATE ( DISTINCTCOUNT ( 'Table'[Shipped On Date] ), ALLEXCEPT ( 'Table', 'Table'[Order Number], 'Table'[Ordered On Date] ) ) ) VAR TotalShipments = SUMX ( ShipmentsPerOrder, [Shipments] ) VAR TotalOrders = COUNTROWS ( Orders ) RETURN DIVIDE ( TotalShipments, TotalOrders )Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi RichardJChester ,
Please try:
Avg Shipment Count2 =
VAR OrderDates =
VALUES ( 'Table'[Ordered On Date] )
VAR Orders =
SUMMARIZE ( 'Table', 'Table'[Order Number], 'Table'[Ordered On Date] )
VAR ShipmentsPerOrder =
ADDCOLUMNS (
Orders,
"Shipments",
CALCULATE (
DISTINCTCOUNT ( 'Table'[Shipped On Date] ),
ALLEXCEPT ( 'Table', 'Table'[Order Number], 'Table'[Ordered On Date] )
)
)
VAR TotalShipments =
SUMX ( ShipmentsPerOrder, [Shipments] )
VAR TotalOrders =
COUNTROWS ( Orders )
RETURN
DIVIDE ( TotalShipments, TotalOrders )
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Thank you very much! This helped a tremendous amount!
Rich