Combine totals for two rows without grouping and losing columns.

KCantor

New member
Joined
Apr 4, 2016
Messages
15
Reaction score
0
Points
0
I have a conundrum. We have a rep that has returned after a previous stint here. He has a new rep ID. I need to combine his new numbers with his old numbers but am unsure how to do that. I don't want to lose other information in columns like I would if I used group, I need all of the numbers. Is this possible? Sample data is below. I would like for BFREE and BFREE1 to show in a single row with combined totals, summed up.
Any help on this?

RepQuotesQuoted AmountOrdersOrdered AmountInvoicesInvoiced AmountCreditsCredited AmountConvertedConverted AmountNet Invoiced Amount
CBRADIO32141779.0180162368.1457113533.92159.2102155433.85155374.65
Pwolf51371960.5845126254.5101115827.6433600.84160172429.58168828.74
BFREE35104919.1293208095.0366123819.3567806.22127236505.79228699.57
BFREE112088.851154.331154.3300000
CAX32195675.572323737.617358371.633269.0612388080.9787811.91
PTRUCK25143723.142383394.5766105009.85113878.2119146371.49132493.29
PHARVEY36435645.081237907.975369161.75891.438562635.4861744.05
 
My first thought is to do a replace values on the Rep column and replace any instance of BFREE1 with BFREE. Then group by the Rep column, and add back in all of your other columns. Sum each one and give it the same name.

attachment.php


Here's the code in M:

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Rep", type text}, {"Quotes", Int64.Type}, {"Quoted Amount", type number}, {"Orders", Int64.Type}, {"Ordered Amount", type number}, {"Invoices", Int64.Type}, {"Invoiced Amount", type number}, {"Credits", Int64.Type}, {"Credited Amount", type number}, {"Converted", Int64.Type}, {"Converted Amount", type number}, {"Net Invoiced Amount", type number}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","BFREE1","BFREE",Replacer.ReplaceText,{"Rep"}),
    #"Grouped Rows" = Table.Group(#"Replaced Value", {"Rep"}, {{"Quotes", each List.Sum([Quotes]), type number}, {"Quoted Amount", each List.Sum([Quoted Amount]), type number}, {"Orders", each List.Sum([Orders]), type number}, {"Ordered Amount", each List.Sum([Ordered Amount]), type number}, {"Invoices", each List.Sum([Invoices]), type number}, {"Invoiced Amount", each List.Sum([Invoiced Amount]), type number}, {"Credits", each List.Sum([Credits]), type number}, {"Credited Amount", each List.Sum([Credited Amount]), type number}, {"Converted", each List.Sum([Converted]), type number}, {"Converted Amount", each List.Sum([Converted Amount]), type number}, {"Net Invoiced Amount", each List.Sum([Net Invoiced Amount]), type number}})
in
    #"Grouped Rows"
 

Attachments

  • groupBy.PNG
    groupBy.PNG
    18.3 KB · Views: 41
Back
Top