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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
nixoniraj
Frequent Visitor

Calculate Column Total for multiple columns

Dear Team,

This query is for Power Query Editor in Power BI

 

I have an original Table like this :

nixoniraj_0-1666179281041.png

 

I want to take column total for each country at last part of the table (ie, after 9. Sep) like this :

nixoniraj_1-1666179387697.png

 

Anyhelp would be much appreciated for showing stepwise process.

 

1 REPLY 1
BA_Pete
Super User
Super User

Hi @nixoniraj ,

 

You just need to use Table.InsertRows with List.Sum functions on the country columns:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtRT8ErMU9JRcq0oyC8qKQayTA0MgKQFkIzViVYy0lNwS01CUWBuClJgZABVYayn4JtYhKLCCKZCKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, Type = _t, India = _t, China = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"India", Int64.Type}, {"China", Int64.Type}}),
    
    insertRow =
    Table.InsertRows(chgTypes, Table.RowCount(chgTypes),
        {
            [
                Month = "Grand Total",
                Type = null,
                India = List.Sum(chgTypes[India]),
                China = List.Sum(chgTypes[China])
            ]
        }
    )
in
    insertRow

 

Output:

BA_Pete_1-1666182055681.png

 

Please note, however, that I would strongly recommend against using Power Query for this sort of thing. It's really not what it's designed for.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.