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
umairarshad
Helper II
Helper II

Adding values of two or more rows

Hi all,

I am working in excel power query. I have the following data.

 

umairarshad_0-1735561742598.png

 

and i require below data from the above. 

 

umairarshad_1-1735561775853.png

 

i.e all values of same GSE ID should be added/sum in one row only. how to do it in power query?

Thanks and regards,

 

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

This can be solved using the Power Query `Group By` function, aggregating the `Quantity` column using `Sum` function.

 

You only show a single month, and all `GSE ID`s correspond to a single `GSE`. And all the `Hrs` are identical for a single `GSE ID`. If your actual data is different, you may have to change your groupings.

ronrsnfld_0-1735567462465.png

 

Paste into the Advanced Editor changing the Source line as appropriate

let

//Replace Source line with your actual data source
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{
        {"Year", type text}, {"Station", type text}, {"Month", type text}, 
        {"GSE", type text}, {"GSE ID", type text}, {"Quantity", type number}, 
        {"Hrs", Int64.Type}}),

//Group by all the columns except Quantity
//Sum the Quantity and use some function that will only return a single item in the hours
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Year", "Station", "Month", "GSE", "GSE ID", "Hrs"}, {
        {"Quantity", each List.Sum([Quantity]), type nullable number}
        }),
    #"Reordered Columns" = Table.ReorderColumns(#"Grouped Rows",{"Year", "Station", "Month", "GSE", "GSE ID", "Quantity", "Hrs"})
in
    #"Reordered Columns"

 

Results:

ronrsnfld_1-1735567642775.png

 

 

 

 

 

View solution in original post

3 REPLIES 3
ronrsnfld
Super User
Super User

This can be solved using the Power Query `Group By` function, aggregating the `Quantity` column using `Sum` function.

 

You only show a single month, and all `GSE ID`s correspond to a single `GSE`. And all the `Hrs` are identical for a single `GSE ID`. If your actual data is different, you may have to change your groupings.

ronrsnfld_0-1735567462465.png

 

Paste into the Advanced Editor changing the Source line as appropriate

let

//Replace Source line with your actual data source
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{
        {"Year", type text}, {"Station", type text}, {"Month", type text}, 
        {"GSE", type text}, {"GSE ID", type text}, {"Quantity", type number}, 
        {"Hrs", Int64.Type}}),

//Group by all the columns except Quantity
//Sum the Quantity and use some function that will only return a single item in the hours
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Year", "Station", "Month", "GSE", "GSE ID", "Hrs"}, {
        {"Quantity", each List.Sum([Quantity]), type nullable number}
        }),
    #"Reordered Columns" = Table.ReorderColumns(#"Grouped Rows",{"Year", "Station", "Month", "GSE", "GSE ID", "Quantity", "Hrs"})
in
    #"Reordered Columns"

 

Results:

ronrsnfld_1-1735567642775.png

 

 

 

 

 

Thank you man. It worked using group by function.

uzuntasgokberk
Super User
Super User

Hello @umairarshad ,

 

You can use the solution below the images.

Go to the table that leads to power query.

uzuntasgokberk_0-1735564832481.png

Click Group by. The table is an example data.

uzuntasgokberk_1-1735564873692.png

Example how to do it and result of the table.

uzuntasgokberk_2-1735564907228.png

Lastly, close & load.

Kind Regards,
Gökberk Uzuntaş

📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |

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.