Using sum + unique functions in dynamic arrays

mach82

New Member
Joined
May 20, 2020
Messages
3
Office Version
  1. 365
Hi
I've been playing with dynamic arrays in Excel 365, but there's one thing that I can't figure out.
I have some data in the A:D columns, out of which I want to receive unique values in F:H columns. I use "Choose" function to omit the "Sales Date" column, as I don't need in this specific place.
I'd however like to get the aggregated sales value in the H column, so basically the end result should be Gary MIller from finance with sales value 60270 and Richard Elliot from Finance with sales value 30000.
How should I redifine the formula to achieve my goal? I later on need to sort by sales value descending and I have to do that within one dynamic array formula.

F2=SORT(UNIQUE(CHOOSE({1\2\3};A2:A4;B2:B4;D2:D4));3;-1)

I apprecaite your help a lot.
cho.jpg
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
This is not the optimum solution. But just an option

New Microsoft Excel Worksheet.xlsx
CDEFGHIJKLMN
3
4
5DepartmentNameSales DataSales ValueStep 1
6FinanceGarry miller201960270FinanceGarry miller60270
7FinanceRichard Elliot202010000FinanceRichard Elliot30000
8FinanceRichard Elliot201920000HRPunit10000
9HRPunit201910000HRRahul20000
10HRRahul202020000
11Step 2
12FinanceGarry miller60270
13FinanceRichard Elliot30000
14HRRahul20000
15HRPunit10000
16
17
Sheet1
Cell Formulas
RangeFormula
K6:L9K6=UNIQUE(C6:D10)
M6:M9M6=SUMIFS(F$6:F$10,$C$6:$C$10,K6,$D$6:$D$10,L6)
K12:M15K12=SORT(K6:M9,3,-1)
Dynamic array formulas.
 
Upvote 0
Thx for this solution. I guess it would normally do the trick, though with tens of thousands of records it may not be very convenient to use. I need something more flexible, preferrably using dynamic arrays with a single formula.
 
Upvote 0
Quite a longgggg formual....However, I assume Pivot Table with a dynamic data source is the best way for your case.
Book1.xlsx
ABCDEFGH
1DepartmentNameSales DateSales ValueDepartmentNameSales Value
2FinanceGarry miller201960270FinanceGarry miller60270
3FinanceRichard Elliot202010000FinanceRichard Elliot30000
4FinanceRichard Elliot201920000
Sheet5
Cell Formulas
RangeFormula
F2:H3F2=SORT(IF({1,1,0},UNIQUE(CHOOSE({1,2},A2:A4,B2:B4)),TRANSPOSE(MMULT(TRANSPOSE(ROW(A2:A4)^0),(A2:A4&B2:B4=TRANSPOSE(INDEX(UNIQUE(CHOOSE({1,2},A2:A4,B2:B4)),,1)&INDEX(UNIQUE(CHOOSE({1,2},A2:A4,B2:B4)),,2)))*(D2:D4)))),3,-1)
Dynamic array formulas.
 
Upvote 0
Thx shaowu459 - the formula works great:) I'm really impressed.

I still have to figure out on how it works. I was thinking on adding the filter formula in the future to filter out one of the departments. Is it possible?
 
Upvote 0
I hope i figured something easy with an helper column.

Book1
ABCDEFGHIJ
1
2Shaowu Formulas
3DepartmentNameHelper ColumnSales DateSales ValueDepartmentNameSales Value
4FinancecFinance,c201960270Financec60270
5FinanceaFinance,a202010000Financeb20000
6FinancebFinance,b201920000Financea10000
7
8My sheet
9DepartmentNameSales Value
10Financec60270
11Financeb20000
12Financea10000
13
14
Sheet1
Cell Formulas
RangeFormula
G4:I6G4=SORT(IF({1,1,0},UNIQUE(CHOOSE({1,2},A4:A6,B4:B6)),TRANSPOSE(MMULT(TRANSPOSE(ROW(A4:A6)^0),(A4:A6&B4:B6=TRANSPOSE(INDEX(UNIQUE(CHOOSE({1,2},A4:A6,B4:B6)),,1)&INDEX(UNIQUE(CHOOSE({1,2},A4:A6,B4:B6)),,2)))*(E4:E6)))),3,-1)
C4:C6C4=A4&","&B4
B10:D12B10=SORT(IF({1,1,0},UNIQUE(CHOOSE({1,2},A4:A6,B4:B6)),SUMIFS(E4:E6,C4:C6,UNIQUE(C4:C6))),3,-1)
Dynamic array formulas.


Please point out if there is some error. it will help me develop understanding the formula
 
Upvote 0
Hi @shaowu459

Please help me with {1,1,0} which you have used with if logical.
What does it mean.
Hi, for time difference i just see your post. Yes, the constant array in IF usually used to creat an array with part of the second and third parameters.
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,050
Members
449,206
Latest member
Healthydogs

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