Index Match Max If - Ecommerce Sales Data

dtechhh

New Member
Joined
Dec 5, 2022
Messages
2
Office Version
  1. 2021
Platform
  1. MacOS
Hi there,
I have an array of e-commerce sales data broken down by week, and source and want to create a formula that tells me the best selling product for each medium each week.

After researching around, I think I need to use a combination of INDEX MATCH & MAX, but haven't found the solution I'm looking for.

I think the solution might be having two input files, Week and Medium, then in a 3rd cell, it returns the highest selling product. (and I just update cells 1 & 2)

Below is a sample of the data and columns I have to work with.

ecommerce.xlsx
ABCDEFGHI
1skumediumweekrevenue unitsproduct viewsproduct adds to basketproduct checkoutsBrand
2Product75organic4$34,129.4939937111107BrandI
3Product75organic5$31,168.00354698174BrandI
4Product75cpc4$14,479.18163262727BrandI
5Product15organic4$11,637.70113844431BrandI
6Product75(none)4$11,376.50135892724BrandI
7Product15cpc4$9,051.5583071318BrandI
8Product24organic5$7,641.9862402213BrandI
9Product118cpc3$7,313.7196653127BrandI
10Product118cpc9$7,313.7194582518BrandI
11Product118organic6$7,313.7192193827BrandI
12Product118organic7$7,313.7191473134BrandI
13Product95organic5$7,052.5172351518BrandI
14Product15organic5$6,583.0562091814BrandI
15Product118organic5$6,399.5082282114BrandI
16Product63organic4$6,346.557661413BrandF
17Product75(none)5$6,205.3671471614BrandI
18Product71organic10$5,642.955671213BrandI
19Product118organic3$5,485.2972113218BrandI
20Product75cpc5$5,171.1462131311BrandI
21Product97(none)10$4,938.1741324BrandF
22Product75cpc2$4,701.6756676BrandI
23Product75organic8$4,701.675147165BrandI
24Product24organic8$4,585.1941682011BrandI
25Product118cpc6$4,571.0764742631BrandI
26Product118cpc2$4,571.0764643320BrandI
27Product118organic4$4,571.0762292714BrandI
28Product118organic8$4,571.0761802214BrandI
29Product71organic8$4,232.2141452214BrandI
30Product63cpc2$4,231.04514588BrandF
31Product63organic7$4,231.0459576BrandF
32Product12organic8$4,231.0451041112BrandF
33Product95organic7$4,055.7249398BrandI
Sheet1
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
mediumweekBest SellerBestSales (2).sku
organic434129.49Product75
organic531168Product75
cpc414479.18Product75
(none)411376.5Product75
cpc37313.71Product118
cpc97313.71Product118
organic67313.71Product118
organic77313.71Product118
(none)56205.36Product75
organic105642.95Product71
organic35485.29Product118
cpc55171.14Product75
(none)104938.17Product97
cpc24701.67Product75
organic84701.67Product75
cpc64571.07Product118


Loaded your table to Power Query Editor and performed Group By

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="BestSales"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"medium", "week"}, {{"Best Seller", each List.Max([#"revenue "]), type number}})
in
    #"Grouped Rows"

Then reloaded original data to PQ Editor

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="BestSales"]}[Content]
in
    Source

Then joined the two tables on common fields to get results shown above

Power Query:
let
    Source = Table.NestedJoin(BestSales, {"medium", "week", "Best Seller"}, #"BestSales (2)", {"medium", "week", "revenue "}, "BestSales (2)", JoinKind.LeftOuter),
    #"Expanded BestSales (2)" = Table.ExpandTableColumn(Source, "BestSales (2)", {"sku"}, {"BestSales (2).sku"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded BestSales (2)",{{"Best Seller", Currency.Type}})
in
    #"Changed Type"
 
Upvote 0
Wow, thanks for the quick reply!

I'm not too familiar with power query and will have to do some further research. :)


Do you think the solution is solvable with regular excel functions?
I envisage having two input fields, and a 3rd cell returning a value. similar to this screenshot. (green being where the formula is.
 

Attachments

  • Screenshot 2022-12-06 at 12.01.11 pm.png
    Screenshot 2022-12-06 at 12.01.11 pm.png
    209.9 KB · Views: 14
Upvote 0
You never told what criteria you want for the maximum sales, unit or revenue??
Wow, thanks for the quick reply!

I'm not too familiar with power query and will have to do some further research. :)


Do you think the solution is solvable with regular excel functions?
I envisage having two input fields, and a 3rd cell returning a value. similar to this screenshot. (green being where the formula is.

I chose units for this formula.
Use Ctrl shift enter while entering the formula.

=INDEX($A$2:$A$33,AGGREGATE(14,6,ROW($A$1:$A$32)/--(MAX(IF(($C$2:$C$33=$L$5)*($B$2:$B$33=$L$6),$E$2:$E$33))=IF(($C$2:$C$33=$L$5)*($B$2:$B$33=$L$6),$E$2:$E$33)),1))


I chose revenue for this formula
Use Ctrl shift enter while entering the formula.
=INDEX($A$2:$A$33,AGGREGATE(14,6,ROW($A$1:$A$32)/--(MAX(IF(($C$2:$C$33=$L$5)*($B$2:$B$33=$L$6),$D$2:$D$33))=IF(($C$2:$C$33=$L$5)*($B$2:$B$33=$L$6),$D$2:$D$33)),1))
 

Attachments

  • wwwe.PNG
    wwwe.PNG
    80.5 KB · Views: 14
Upvote 0
Another option
Fluff.xlsm
ABCDEFGHIJKLMN
1skumediumweekrevenue unitsproduct viewsproduct adds to basketproduct checkoutsBrand
2Product75organic434129.4939937111107BrandIcpc2Product75
3Product75organic531168354698174BrandIcpc3Product118
4Product75cpc414479.18163262727BrandIorganic3Product118
5Product15organic411637.7113844431BrandI(none)4Product75
6Product75(none)411376.5135892724BrandIcpc4Product75
7Product15cpc49051.5583071318BrandIorganic4Product75
8Product24organic57641.9862402213BrandI(none)5Product75
9Product118cpc37313.7196653127BrandIcpc5Product75
10Product118cpc97313.7194582518BrandIorganic5Product75
11Product118organic67313.7192193827BrandIcpc6Product118
12Product118organic77313.7191473134BrandIorganic6Product118
13Product95organic57052.5172351518BrandIorganic7Product118
14Product15organic56583.0562091814BrandIorganic8Product75
15Product118organic56399.582282114BrandIcpc9Product118
16Product63organic46346.557661413BrandF(none)10Product97
17Product75(none)56205.3671471614BrandIorganic10Product71
18Product71organic105642.955671213BrandI
19Product118organic35485.2972113218BrandI
20Product75cpc55171.1462131311BrandI
21Product97(none)104938.1741324BrandF
22Product75cpc24701.6756676BrandI
23Product75organic84701.675147165BrandI
24Product24organic84585.1941682011BrandI
25Product118cpc64571.0764742631BrandI
26Product118cpc24571.0764643320BrandI
27Product118organic44571.0762292714BrandI
28Product118organic84571.0761802214BrandI
29Product71organic84232.2141452214BrandI
30Product63cpc24231.04514588BrandF
31Product63organic74231.0459576BrandF
32Product12organic84231.0451041112BrandF
33Product95organic74055.7249398BrandI
34
Data
Cell Formulas
RangeFormula
L2:M17L2=SORT(UNIQUE(B2:C33),{2,1})
N2:N17N2=TAKE(SORT(FILTER($A$2:$D$100,($B$2:$B$100=L2)*($C$2:$C$100=M2)),4,-1),1,1)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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