Calculate and summarize rows into a new table

Lars1

Board Regular
Joined
Feb 3, 2021
Messages
158
Office Version
  1. 365
Platform
  1. Windows
Hi

I am quite new to Power BI, and i am struggling with this problem.

I have a table which contains order lines and with a Gross Weight on each line.
I need this to be calculated in to a new table where Gross Weight is summarized per order.

Could anyone help me with this ?

1638275082270.png
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Using Power Query.

Book1 (version 1).xlsb
ABCDEFGH
1Line NoOrder NoQuantityGross WeightShipping AgentShipment DateStatus1Status2
2112345611.2UPS1/1/202100
3212345611.3UPS1/1/202100
4312345611.2UPS1/1/202100
5189451211DHL1/3/202111
6289451220.8DHL1/3/202111
7389451210.6DHL1/3/202111
8489451220.4DHL1/3/202111
9165487110.2UPS1/1/202100
10265487121.2UPS1/1/202100
11125789611FedEx1/5/202111
12225789610.8FedEx1/5/202111
13325789621.2FedEx1/5/202111
14425789621FedEx1/5/202111
15525789630.8FedEx1/5/202111
16
17
18Order NoShipping AgentShipment DateStatus1Status2Weight Per Order
19123456UPS44197003.7
20894512DHL44199114
21654871UPS44197002.6
22257896FedEx44201118.6
Sheet5


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Total = Table.AddColumn(Source, "Weight Per Order", each [Quantity]*[Gross Weight]),
    Group = Table.Group(Total, {"Order No", "Shipping Agent", "Shipment Date", "Status1", "Status2"}, {{"Weight Per Order", each List.Sum([Weight Per Order]), type number}})
in
    Group
 
Upvote 0
Using Power Query.

Book1 (version 1).xlsb
ABCDEFGH
1Line NoOrder NoQuantityGross WeightShipping AgentShipment DateStatus1Status2
2112345611.2UPS1/1/202100
3212345611.3UPS1/1/202100
4312345611.2UPS1/1/202100
5189451211DHL1/3/202111
6289451220.8DHL1/3/202111
7389451210.6DHL1/3/202111
8489451220.4DHL1/3/202111
9165487110.2UPS1/1/202100
10265487121.2UPS1/1/202100
11125789611FedEx1/5/202111
12225789610.8FedEx1/5/202111
13325789621.2FedEx1/5/202111
14425789621FedEx1/5/202111
15525789630.8FedEx1/5/202111
16
17
18Order NoShipping AgentShipment DateStatus1Status2Weight Per Order
19123456UPS44197003.7
20894512DHL44199114
21654871UPS44197002.6
22257896FedEx44201118.6
Sheet5


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Total = Table.AddColumn(Source, "Weight Per Order", each [Quantity]*[Gross Weight]),
    Group = Table.Group(Total, {"Order No", "Shipping Agent", "Shipment Date", "Status1", "Status2"}, {{"Weight Per Order", each List.Sum([Weight Per Order]), type number}})
in
    Group
Hi
Thank you so much.

I am sorry, but i should have stated it should be a DAX solution, to be used in Power Bi Tables.
Sorry
 
Upvote 0
Never really worked with DAX before. I still had to add a column to the table in Power BI, just like I would have with Power Query, where I multiplied Quantity * Weight.

But then, in DAX, I used the following code and it produced the same output as my first post.

Power Query:
Table =
SUMMARIZE (
    Table5,
    Table5[Order No],Table5[Shipping Agent],Table5[Shipment Date].[Date],Table5[Status1],Table5[Status2],
   "Weight Per Order", SUM ( Table5[Weight Per Order]  )
)
 
Upvote 0
Think I figured it out.

Power Query:
Table = 
SUMMARIZECOLUMNS(  
Table5[Order No],
Table5[Shipping Agent],
Table5[Shipment Date].[Date],
Table5[Status1],
Table5[Status2],
"Weight Per Order", SUMX(Table5, Table5[Quantity] * Table5[Gross Weight])  
)
 
Upvote 0
Solution
Think I figured it out.

Power Query:
Table =
SUMMARIZECOLUMNS( 
Table5[Order No],
Table5[Shipping Agent],
Table5[Shipment Date].[Date],
Table5[Status1],
Table5[Status2],
"Weight Per Order", SUMX(Table5, Table5[Quantity] * Table5[Gross Weight]) 
)
Perfect.
I think we got it.

THANK YOU SO MUCH
 
Upvote 0

Forum statistics

Threads
1,223,692
Messages
6,173,853
Members
452,535
Latest member
berdex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top