Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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 No | Client | Ledger | Jan-22 | Feb-22 | Mar-22 | Apr-22 | May-22 | Jun-22 | Jul-22 | Aug-22 | Sep-22 | Oct-22 | Nov-22 | Dec-22 |
1 | Client1 | Travel | 50 | 50 | 50 | 50 | 50 | 50 | 50 | 100 | 100 | 100 | 100 | 100 |
2 | Client2 | Subcontractors | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 600 | 600 | 600 | 600 | 600 |
3 | Client3 | Subcontractors | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 200 | 200 | 200 | 200 | 200 |
4 | Client4 | Travel & Accommodation | 150 | 150 | 150 | 150 | 150 | 150 | 150 | 2,500 | 2,500 | 2,500 | 2,500 | 2,500 |
5 | Client5 | Subcontractors | 15,000 | 15,000 | 15,000 | 15,000 | 15,000 | 15,000 | 15,000 | 100 | 100 | 100 | 100 | 100 |
Total | 15,400 | 15,400 | 15,400 | 15,400 | 15,400 | 15,400 | 15,400 | 3,500 | 3,500 | 3,500 | 3,500 | 3,500 |
How can I simply add total of every 3 months to create quarterly totals? Thanks!
Cheers,
Troy
Solved! Go to Solution.
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"
It worked! Thank you so much Vijay 🙂
Cheers,
Troy
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"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.