Level up the data

vcheung

New Member
Joined
Jan 7, 2021
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have a set of sales data with customer name, invoice date, account code, etc., and I want to have your help how to level up this set of data to group the sales data by account code for each customer name to have another set of data?

For example as below.

BEFORE
DateCustomer NameAccount codeRegionAmount
1/1/2021​
ABC Ltd.60100North
600​
1/1/2021​
ABC Ltd.60100South
300​
15/1/2021​
DEF Ltd.61000North
1200​
10/2/2021​
ABC Ltd.60100South
500​
28/2/2021​
DEF Ltd.61000North
20​
AFTER
Customer NameAccount codeRegionAmount
ABC Ltd
60100​
North
600​
ABC Ltd
60100​
South
800​
DEF Ltd.
61000​
North
1220​


Best Regards

V. Cheung
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try post sample with XL2BB in order to get cell address of data BEFORE and AFTER
 
Upvote 0
In edit window, on top-right menu, you can see XL2BB menu, click to download and run it.
 
Upvote 0
A Power Query Solution

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Amount", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Customer Name", "Account code", "Region"}, {{"Total", each List.Sum([Amount]), type any}})
in
    #"Grouped Rows"

Book3
ABCDEFGHIJ
1DateCustomer NameAccount codeRegionAmountCustomer NameAccount codeRegionTotal
21/1/2021ABC Ltd.60100North600.00ABC Ltd.60100North600
31/1/2021ABC Ltd.60100South300.00ABC Ltd.60100South800
41/15/2021DEF Ltd.61000North1200.00DEF Ltd.61000North1220
52/10/2021ABC Ltd.60100South500.00
62/28/2021DEF Ltd.61000North20.00
Sheet1
 
Upvote 0
Hi
May try
VBA Code:
Sub test()
Dim i As Long
Dim a As Variant
a = Cells(1, 1).CurrentRegion
 With CreateObject("scripting.dictionary")
  For i = 1 To UBound(a)
  t = a(i, 2) & a(i, 4)
    If Not .Exists(t) Then
    .Add t, Array(a(i, 2), a(i, 3), a(i, 4), a(i, 5))
    Else
  x = .Item(t):  x(3) = x(3) + a(i, 5):  .Item(t) = x
    End If
   Next
    Cells(1, 8).Resize(.Count, 4) = Application.Transpose(Application.Transpose(.items))
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,656
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top