Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Items Per Order - DAX Measure

Hi Experts

 

How would you calculate the items per order based on the sample data in the table below..

For the first Order ID we have one item ordered and the distinct count of the Order Id = 1 so 1/1 = 1

 

Items Per Order = SUM(FACTSalesOrderTable[total_qty_ordered])/DISTINCTCOUNT(FACTSalesOrderTable[increment_id])

 

QTYOrder ID Answer
110502 1
210503 6
310503 6
110503 6
1 ACCEPTED SOLUTION

@Anonymous , Try like

divide(SumX(filter(allselected(FACTSalesOrderTable) , FACTSalesOrderTable[Order ID] = max(FACTSalesOrderTable[Order ID])), FACTSalesOrderTable[Qty]), distinctcount(FACTSalesOrderTable[Order ID]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous , Based on what I got. I think it should be like

divide(count(FACTSalesOrderTable[Order ID]), distinctcount(FACTSalesOrderTable[Order ID]))

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Has to be the order qty assoicated with that Order ID...

Anonymous
Not applicable

hi Amit so for the second Order ID we have ordered 6 items and our distinctcount of order ID is 1 - hence 6/1 = 6 items per order....logic

@Anonymous , do you need lines or qty. I thought lines

Sum qty , distinct count of Order ID

divide(Sum(FACTSalesOrderTable[Qty]), distinctcount(FACTSalesOrderTable[Order ID]))

 

if you need line below , use count

 

divide(Sum(FACTSalesOrderTable[Qty]), count(FACTSalesOrderTable[Order ID]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Not getting the right answer.....i am expecting the results as per the table....

@Anonymous , Try like

divide(SumX(filter(allselected(FACTSalesOrderTable) , FACTSalesOrderTable[Order ID] = max(FACTSalesOrderTable[Order ID])), FACTSalesOrderTable[Qty]), distinctcount(FACTSalesOrderTable[Order ID]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.