Trying to take the before photo and make it look like after in Excel (Ill take Access too if you got it). If possible, I need something my boss can run and do it himself simply. Basically, just want to build a template that even he can run without much trouble. Basically need to merge the rows and sum TWO columns: Tax Collected and Tax Rate.
Merge Rows and total 2 categories
- MarcoTex
- Thread is marked as Resolved.
-
-
Photos are fairly useless as we cannot manipulate the data in them. Suggest you upload your data in a file so that we can test our solutions before offering them up to you. Additionally, we are all volunteers with limited time available to help. Don't make us retype your data and guess at your formatting. Help us to help you by making it easy for us to help.
-
Apologies for that. Didn't realize I could upload data. Will do tomorrow when I am back at work. Thank you.
-
Data changed to spreadsheets. Basically, need to merge rows by Invoice Line and sum both the Tax Rate and Tax Collected columns; leaving the other columns untouched. Also, this is a basic spreadsheet with only 9 rows. The solution would need to work for spreadsheets with hundreds to thousands of rows. Any help would be appreciated. Thank you.
-
Hi,
Ideal question for alansidman
For sure, Alan will come up with a brilliant Power Query solution to group by Invoice Line (Column H)
and to sum only Columns AM and AN...
Note a Pivot Table could also handle this question rather quickly
-
-
Yes, I can build a pivot table but its time consuming and my boss doesn't want to. I am looking for a solution he can do easily without needing me. If it at all possible.
-
Hi,
To be reviewed by Alan ...
Codelet Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Grouped Rows" = Table.Group(Source, {"Invoice Line"}, {{"Sum of Tax Collected", each List.Sum([Tax Collected]), type number}, {"Sum of Tax Rate", each List.Sum([Tax Rate]), type number}}) in #"Grouped Rows"
Hope this will help
-
Hi Mark,
Should you need to retain All the Other 44 Columns for your Group By ...
below is the modified M code :
Codelet Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Grouped Rows" = Table.Group(Source, {"Co Code","Billing Party","Invoice Number","Invoice Date","Customer Class","Customer Number","Customer Name","Invoice Line","TPC","TPC Name","Line Description","Prod Type","Item Name","Tax Category","Distr Method","DesignLive","GeoTool","OrderForm","RptUsage","Tax Result","Exempt Code","OBM Brand","Product Owner","SepStatedCat","PerformLoc","Sales Person","Linked Invoice","UseTax Reason","SourceMethod","ClientBill State","ClientHQ State","ShipTo Zip","ZipSellPrice","ZipQuantity","ShipTo State","ShipTo County","ShipTo City","Tax Base Amount","ShipFrom Plant","ShipFrom State","ShipFrom Zip","Interim Plant","Osprey OrderID","Osprey MailDropID","Osprey CustNo"}, {{"Sum of Tax Collected", each List.Sum([Tax Collected]), type number}, {"Sum of Tax Rate", each List.Sum([Tax Rate]), type number}}) in #"Grouped Rows"
and attached is your Test file
-
Once you have tested out the M code, feel free to share your comments
-
Will do. Been stuck with other tasks in the meantime.
-
-
So, to ask a dumb Q, how do I use this query on my data? Thanks for helping this newb whose boss thinks he knows what he's doing haha.
-
No such thing as a stupid question !!!
Indeed, unlike Excel, Power Query has its own "engine" and does not update itself automatically ...
If the test file attached in post #8 (Test MarcoTex) does produce your expected result ... ( you have not answered this question ....
)
probably the easiest solution, for you, is to copy your entire database from your current file to this test file ... and, then,
From Excel's main menu, just click on Data > Refresh All
-
-
Here is how I would do it.
1. Group the table on the Invoice Line and sum the two tax columns
Codelet Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Invoice Date", type date}, {"Tax Collected", type number}, {"Tax Rate", Percentage.Type}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Invoice Line"}, {{"Sum of Tax Collected", each List.Sum([Tax Collected]), type nullable number}, {"Sum of Tax Rate", each List.Sum([Tax Rate]), type nullable number}}) in #"Grouped Rows"
Then Merge (join) the new query with the original data (ie. Merge back on itself)
Codelet Source = Table.NestedJoin(Table1, {"Invoice Line"}, #"Table1 (2)", {"Invoice Line"}, "Table1 (2)", JoinKind.LeftOuter), #"Expanded Table1 (2)" = Table.ExpandTableColumn(Source, "Table1 (2)", {"Co Code", "Billing Party", "Invoice Number", "Invoice Date", "Customer Class", "Customer Number", "Customer Name", "TPC", "TPC Name", "Line Description", "Prod Type", "Item Name", "Tax Category", "Distr Method", "DesignLive", "GeoTool", "OrderForm", "RptUsage", "Tax Result", "Exempt Code", "OBM Brand", "Product Owner", "SepStatedCat", "PerformLoc", "Sales Person", "Linked Invoice", "UseTax Reason", "SourceMethod", "ClientBill State", "ClientHQ State", "ShipTo Zip", "ZipSellPrice", "ZipQuantity", "ShipTo State", "ShipTo County", "ShipTo City", "Tax Base Amount", "ShipFrom Plant", "ShipFrom State", "ShipFrom Zip", "Interim Plant", "Osprey CustNo", "Osprey OrderID", "Osprey MailDropID"}, {"Table1 (2).Co Code", "Table1 (2).Billing Party", "Table1 (2).Invoice Number", "Table1 (2).Invoice Date", "Table1 (2).Customer Class", "Table1 (2).Customer Number", "Table1 (2).Customer Name", "Table1 (2).TPC", "Table1 (2).TPC Name", "Table1 (2).Line Description", "Table1 (2).Prod Type", "Table1 (2).Item Name", "Table1 (2).Tax Category", "Table1 (2).Distr Method", "Table1 (2).DesignLive", "Table1 (2).GeoTool", "Table1 (2).OrderForm", "Table1 (2).RptUsage", "Table1 (2).Tax Result", "Table1 (2).Exempt Code", "Table1 (2).OBM Brand", "Table1 (2).Product Owner", "Table1 (2).SepStatedCat", "Table1 (2).PerformLoc", "Table1 (2).Sales Person", "Table1 (2).Linked Invoice", "Table1 (2).UseTax Reason", "Table1 (2).SourceMethod", "Table1 (2).ClientBill State", "Table1 (2).ClientHQ State", "Table1 (2).ShipTo Zip", "Table1 (2).ZipSellPrice", "Table1 (2).ZipQuantity", "Table1 (2).ShipTo State", "Table1 (2).ShipTo County", "Table1 (2).ShipTo City", "Table1 (2).Tax Base Amount", "Table1 (2).ShipFrom Plant", "Table1 (2).ShipFrom State", "Table1 (2).ShipFrom Zip", "Table1 (2).Interim Plant", "Table1 (2).Osprey CustNo", "Table1 (2).Osprey OrderID", "Table1 (2).Osprey MailDropID"}), #"Removed Duplicates" = Table.Distinct(#"Expanded Table1 (2)", {"Invoice Line"}) in #"Removed Duplicates"
-
-
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!