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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Troyvan
Helper I
Helper I

Adding columns subtotal

Hi All, 

 

Apologies if this has been answered previously. I'm trying to creat a column showing total per quarter but I can't seem to add selected column totals here. My data looks like this: 

Job NoClientLedgerJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
1Client1Travel 50505050505050100100100100100
2Client2Subcontractors100100100100100100100600600600600600
3Client3Subcontractors100100100100100100100200200200200200
4Client4Travel & Accommodation 1501501501501501501502,5002,5002,5002,5002,500
5Client5Subcontractors15,00015,00015,00015,00015,00015,00015,000100100100100100
Total  15,40015,40015,40015,40015,40015,40015,4003,5003,5003,5003,5003,500

 

How can I simply add total of every 3 months to create quarterly totals? Thanks! 

 

Cheers,
Troy

1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXLOyUzNKwGxQooSy1JzgAxTA4KEoQFuMlYnWskIbjKIFVyalJyfV1KUmFySX1RMQDsqaYaHBFlkDLfImDKLjPCQIItM4BaZwMNKIabUwMDITMExOTk/Nzc/JbEkMz8PZCIkjIggjXRMDQjTIPtN4fabYvWoqY4BxDfkMfDFZywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Job No" = _t, Client = _t, Ledger = _t, #"Jan-22" = _t, #"Feb-22" = _t, #"Mar-22" = _t, #"Apr-22" = _t, #"May-22" = _t, #"Jun-22" = _t, #"Jul-22" = _t, #"Aug-22" = _t, #"Sep-22" = _t, #"Oct-22" = _t, #"Nov-22" = _t, #"Dec-22" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Job No", Int64.Type}, {"Client", type text}, {"Ledger", type text}, {"Jan-22", Int64.Type}, {"Feb-22", Int64.Type}, {"Mar-22", Int64.Type}, {"Apr-22", Int64.Type}, {"May-22", Int64.Type}, {"Jun-22", Int64.Type}, {"Jul-22", Int64.Type}, {"Aug-22", Int64.Type}, {"Sep-22", Int64.Type}, {"Oct-22", Int64.Type}, {"Nov-22", Int64.Type}, {"Dec-22", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Ledger", "Client", "Job No"}, "Attribute", "Value"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Attribute", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Quarter", each "Q"&Text.From(Number.RoundUp(Date.Month([Attribute])/3,0))),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Quarter"}, {{"Total", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

 

View solution in original post

2 REPLIES 2
Troyvan
Helper I
Helper I

It worked! Thank you so much Vijay 🙂

 

Cheers,
Troy

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXLOyUzNKwGxQooSy1JzgAxTA4KEoQFuMlYnWskIbjKIFVyalJyfV1KUmFySX1RMQDsqaYaHBFlkDLfImDKLjPCQIItM4BaZwMNKIabUwMDITMExOTk/Nzc/JbEkMz8PZCIkjIggjXRMDQjTIPtN4fabYvWoqY4BxDfkMfDFZywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Job No" = _t, Client = _t, Ledger = _t, #"Jan-22" = _t, #"Feb-22" = _t, #"Mar-22" = _t, #"Apr-22" = _t, #"May-22" = _t, #"Jun-22" = _t, #"Jul-22" = _t, #"Aug-22" = _t, #"Sep-22" = _t, #"Oct-22" = _t, #"Nov-22" = _t, #"Dec-22" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Job No", Int64.Type}, {"Client", type text}, {"Ledger", type text}, {"Jan-22", Int64.Type}, {"Feb-22", Int64.Type}, {"Mar-22", Int64.Type}, {"Apr-22", Int64.Type}, {"May-22", Int64.Type}, {"Jun-22", Int64.Type}, {"Jul-22", Int64.Type}, {"Aug-22", Int64.Type}, {"Sep-22", Int64.Type}, {"Oct-22", Int64.Type}, {"Nov-22", Int64.Type}, {"Dec-22", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Ledger", "Client", "Job No"}, "Attribute", "Value"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Attribute", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Quarter", each "Q"&Text.From(Number.RoundUp(Date.Month([Attribute])/3,0))),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Quarter"}, {{"Total", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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