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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
TomSinAA
Helper III
Helper III

Dax for cost per unit for a delivery

Hello,  I am trying to create a measure for the cost per unit for a delivery.  I have a measure for delivery cost. So I am trying to create a measure for total units in a delivery then a measure to divide total units by total delivery cost.  Here is my data structure:

DeliveryShipmentDelivery CostUnitsTotal UnitsCost Per Unit
A1$205  
A2$203  
A3$206  
A4$20216$1.25
B6$303  
B7$308  
B8$302  
B9$30114$2.14

 

I want to create measures to get the data in red: Total  Units and Cost Per Unit.  I have a measure that gets the Max Cost for each delivery since each row for a delivery has the same cost value. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Add only delivery and cost column in table visual..and add above two measures...

Else try to create new table which i have suggested.

View solution in original post

5 REPLIES 5
TomSinAA
Helper III
Helper III

clarification: the 2 columns on the right (Total Units and Cost Per Unit)  in the table are not in my data model.  I want to create measures for them.

Anonymous
Not applicable

 Hi @TomSinAA 

 

New table=

Summerize(table,table[delivery],table[cost],"total units",sum(table[units]),"cost per unit",divide(table[cost],sum(table[units])))

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Anonymous
Not applicable

or simply drag delivery, cost in table visual.

 

and create two measure and drag them into table visual

 

Total units=sum(table[unit])

 

cost per unit=divide(table[cost],sum(table[unit]),0)

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

 

 

 

The measure: Total units=sum(table[unit])

displays the same value as the units for each row. It does not add add units in a delivery

 

Anonymous
Not applicable

Add only delivery and cost column in table visual..and add above two measures...

Else try to create new table which i have suggested.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.