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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.