Sort transaction file into Sales Summary

Rogiv

New Member
Joined
May 9, 2019
Messages
2
Hi everyone, I have a huge file about transaction that has 5 columns (Date, Product Name, Quantity, Price, Total Price), example like below:

Date Product Name Quantity Price Total
2019-01-01 A 2 $100 $200
2019-01-01 B 5 $50 $250
2019-01-01 B 50 $50 $2,500
2019-01-01 C 3 $30 $90
2019-02-01 B 1 $50 $50
2019-02-01 B 5 $50 $250
2019-02-01 B 1 $50 $50
2019-02-01 B 10 $50 $500
2019-03-01 C 3 $30 $90
2019-03-01 B 1 $50 $50

My question is, is there a way to sort this file into a total amount sold for every product in every month?

I expect the output will be something like:

Jan Feb Mar Total
A 2 0 0 2
B 55 17 1 73
C 3 0 3 6


Thank you in advance!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
try this


Book1
ABCDEFGHIJK
1DateProductQuantityPriceTotalJanFebMarTotal
201/01/2019A2$100$200A2002
301/01/2019B5$50$250B5517173
401/01/2019B50$50$2,500C3036
501/01/2019C3$30$90
601/02/2019B1$50$50
701/02/2019B5$50$250
801/02/2019B1$50$50
901/02/2019B10$50$500
1001/03/2019C3$30$90
1101/03/2019B1$50$50
Sheet1
Cell Formulas
RangeFormula
H2=SUMPRODUCT(($B$2:$B$11=$G2)*(MONTH($A$2:$A$11)=MONTH("1/"&H$1)),$C$2:$C$11)
 
Last edited:
Upvote 0
with PowerQuery

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Date[/td][td=bgcolor:#5B9BD5]Product[/td][td=bgcolor:#5B9BD5]Quantity[/td][td=bgcolor:#5B9BD5]Price[/td][td=bgcolor:#5B9BD5]Total[/td][td][/td][td=bgcolor:#70AD47]Product[/td][td=bgcolor:#70AD47]January[/td][td=bgcolor:#70AD47]February[/td][td=bgcolor:#70AD47]March[/td][td=bgcolor:#70AD47]Total[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
01/01/2019​
[/td][td=bgcolor:#DDEBF7]A[/td][td=bgcolor:#DDEBF7]
2​
[/td][td=bgcolor:#DDEBF7]$100[/td][td=bgcolor:#DDEBF7]$200[/td][td][/td][td=bgcolor:#E2EFDA]A[/td][td=bgcolor:#E2EFDA]
2​
[/td][td=bgcolor:#E2EFDA]
0​
[/td][td=bgcolor:#E2EFDA]
0​
[/td][td=bgcolor:#E2EFDA]
2​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
01/01/2019​
[/td][td]B[/td][td]
5​
[/td][td]$50[/td][td]$250[/td][td][/td][td]B[/td][td]
55​
[/td][td]
17​
[/td][td]
1​
[/td][td]
73​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
01/01/2019​
[/td][td=bgcolor:#DDEBF7]B[/td][td=bgcolor:#DDEBF7]
50​
[/td][td=bgcolor:#DDEBF7]$50[/td][td=bgcolor:#DDEBF7]$2,500[/td][td][/td][td=bgcolor:#E2EFDA]C[/td][td=bgcolor:#E2EFDA]
3​
[/td][td=bgcolor:#E2EFDA]
0​
[/td][td=bgcolor:#E2EFDA]
3​
[/td][td=bgcolor:#E2EFDA]
6​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
01/01/2019​
[/td][td]C[/td][td]
3​
[/td][td]$30[/td][td]$90[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
01/02/2019​
[/td][td=bgcolor:#DDEBF7]B[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]$50[/td][td=bgcolor:#DDEBF7]$50[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
01/02/2019​
[/td][td]B[/td][td]
5​
[/td][td]$50[/td][td]$250[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
01/02/2019​
[/td][td=bgcolor:#DDEBF7]B[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]$50[/td][td=bgcolor:#DDEBF7]$50[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
01/02/2019​
[/td][td]B[/td][td]
10​
[/td][td]$50[/td][td]$500[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
01/03/2019​
[/td][td=bgcolor:#DDEBF7]C[/td][td=bgcolor:#DDEBF7]
3​
[/td][td=bgcolor:#DDEBF7]$30[/td][td=bgcolor:#DDEBF7]$90[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
01/03/2019​
[/td][td]B[/td][td]
1​
[/td][td]$50[/td][td]$50[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    RC = Table.RemoveColumns(Source,{"Price", "Total"}),
    Month = Table.TransformColumns(RC, {{"Date", each Date.MonthName(_), type text}}),
    Pivot = Table.Pivot(Month, List.Distinct(Month[Date]), "Date", "Quantity", List.Sum),
    TotalRows = Table.AddColumn(Pivot, "Total", each List.Sum({[January], [February], [March]}), type number)
in
    TotalRows[/SIZE]
 
Last edited:
Upvote 0
or simpler version

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Date[/td][td=bgcolor:#5B9BD5]Product[/td][td=bgcolor:#5B9BD5]Quantity[/td][td=bgcolor:#5B9BD5]Price[/td][td=bgcolor:#5B9BD5]Total[/td][td][/td][td=bgcolor:#DDEBF7]Sum of Quantity[/td][td=bgcolor:#DDEBF7]Date[/td][td=bgcolor:#DDEBF7][/td][td=bgcolor:#DDEBF7][/td][td=bgcolor:#DDEBF7][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
Jan​
[/td][td=bgcolor:#DDEBF7]A[/td][td=bgcolor:#DDEBF7]
2​
[/td][td=bgcolor:#DDEBF7]$100[/td][td=bgcolor:#DDEBF7]$200[/td][td][/td][td=bgcolor:#DDEBF7]Product[/td][td=bgcolor:#DDEBF7]
Jan
[/td][td=bgcolor:#DDEBF7]
Feb
[/td][td=bgcolor:#DDEBF7]
Mar
[/td][td=bgcolor:#DDEBF7]Grand Total[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
Jan​
[/td][td]B[/td][td]
5​
[/td][td]$50[/td][td]$250[/td][td][/td][td]A[/td][td]
2​
[/td][td][/td][td][/td][td]
2​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
Jan​
[/td][td=bgcolor:#DDEBF7]B[/td][td=bgcolor:#DDEBF7]
50​
[/td][td=bgcolor:#DDEBF7]$50[/td][td=bgcolor:#DDEBF7]$2,500[/td][td][/td][td]B[/td][td]
55​
[/td][td]
17​
[/td][td]
1​
[/td][td]
73​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
Jan​
[/td][td]C[/td][td]
3​
[/td][td]$30[/td][td]$90[/td][td][/td][td]C[/td][td]
3​
[/td][td][/td][td]
3​
[/td][td]
6​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
Feb​
[/td][td=bgcolor:#DDEBF7]B[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]$50[/td][td=bgcolor:#DDEBF7]$50[/td][td][/td][td=bgcolor:#DDEBF7]Grand Total[/td][td=bgcolor:#DDEBF7]
60
[/td][td=bgcolor:#DDEBF7]
17
[/td][td=bgcolor:#DDEBF7]
4
[/td][td=bgcolor:#DDEBF7]
81
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
Feb​
[/td][td]B[/td][td]
5​
[/td][td]$50[/td][td]$250[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
Feb​
[/td][td=bgcolor:#DDEBF7]B[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]$50[/td][td=bgcolor:#DDEBF7]$50[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
Feb​
[/td][td]B[/td][td]
10​
[/td][td]$50[/td][td]$500[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
Mar​
[/td][td=bgcolor:#DDEBF7]C[/td][td=bgcolor:#DDEBF7]
3​
[/td][td=bgcolor:#DDEBF7]$30[/td][td=bgcolor:#DDEBF7]$90[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
Mar​
[/td][td]B[/td][td]
1​
[/td][td]$50[/td][td]$50[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


change Date to custom format: mmm then create PivotTable
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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