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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
GreenP
Regular Visitor

DAX - First Average, then Sum

Hi Experts,

I have a table like below:

Shipment NumberMaterial NumberDistanceItem Weight
S1M00110010
S1M00210010
S1M00310010
S2M00420010
S2M00520050
S3M00630010
S3M00730010
S3M00830050
S4M00940080
S5M01050010
S5M01150010

 

Each shipment can have multiple materials.

We need DAX to calculate the following measures:

  • Total distance covered by all shipments, which, in the above table, should be (100+200+300+400+500) = 1500 Km
  • Total weight = 260 Kg
  • Total weight/Km = 260/1500

 

If someone can help with the DAX, it would be very helpful.

 

Thanks

 

 

 

3 REPLIES 3
johnt75
Super User
Super User

You can use

Total distance covered =
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Shipment number], 'Table'[Distance] ),
    'Table'[Distance]
)

Total Weight = SUM( 'Table'[Item Weight])

Total Weight/KM = DIVIDE( [Total Weight], [Total distance covered])

Hi, The SUMX function does not accept a field as its 3rd argument. We need an aggregated value there. Can you help us?

There isn't a third argument to SUMX, I think you may have a typo in your code. Double check it against what I posted.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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