Alternative to complex SumProduct to rank data by specific variable

edward_raddish

New Member
Joined
May 8, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all,
I work for a finance company, I receive a large data set via a webhook from a cloud software provider. We use the dataset to do client reporting.
The dataset has all of the investments each client has. There is 217 rows, across 15 different clients.
When we present the information to clients we order the investments from biggest to smallest based on specific criteria. To make this as automated as possible, we have implemented a complex SUMPRODUCT formula which gives us the ranking of each investment for each client, depending on the category (please see column L in the below).

Unfortunately for my laptop, this is VERY slow and makes it impossible to run.

I am looking for an alternative way to achieve this.

Options I am thinking of:
1. A way to optimise current formula ?
2. A quicker / cleaner formula to achieve the ranking (almost a RANK IF type outcome)
3. A Macro to create the rank numbers as hardcodes so it doesn't need the dynamic calculation (note, I don't have any experience using macros, so this isn't my preferred option)
4. Potentially splitting the source data into different tabs (which becomes less scalable as we add new clients...).


Client Reporting_MASTER_Share.xlsx
ABCDEFGHIJKL
1
2
3
4
5
6Last Refresh: 3/04/2023 8:47:10 PM
7Received 216 row(s)
8
9
10
11DescriptionAccount NumberInstrument TypeCurrencyNotional QuantityMarket PriceValuePercent of PortfolioRank
12Company E6220002-11EquityAUD2057110836.2490.0222778511
13Settled Cash - AUD6220002-11CashAUD3989.2347232667.2023360.00053613
14Settled Cash - SEK6220002-11CashSEK64685.450526233.1801690.001252862
15Unsettled Cash - USD6220002-11CashUSD-2283.83822-2283.83822-0.000459054
16Settled Cash - USD6220002-11CashUSD10835.5883310835.588330.002177931
17Company A6220002-11EquityUSD13365917507.250.1844171
18Company G6220002-11EquityUSD6682445221.660.08948865
19Company F6220002-11EquityUSD5622751211.640.150991932
20Company C6220002-11EquityUSD12432525873.60.105699473
21Company H6220002-11EquityUSD3171230404.860.0463108810
22Company I6220002-11EquityUSD4089256094.070.051474369
23Company J6220002-11EquityUSD17318429140.040.086256236
24Company D6220002-11EquityUSD24662478936.040.096265124
25Company B6220002-11EquityUSD34082284925.520.057269427
26Company K6220002-11EquitySEK15503260833.31410.052426948
27Company L6220002-11Private EquityAUD10333264775.15540.053219241
28Company EPlaceholderEquityAUD10000538824.740.094180585
29Settled Cash - AUDPlaceholderCashAUD2200014709.20.0025712
30Settled Cash - USDPlaceholderCashUSD640958.351640958.3510.11203241
31Company APlaceholderEquityUSD96006590400.115192874
32Company GPlaceholderEquityUSD72004797360.083852526
33Company FPlaceholderEquityUSD7160956719.20.167223892
34Company CPlaceholderEquityUSD175007402500.129387473
35Company DPlaceholderEquityUSD225004369500.0763747
36Company BPlaceholderEquityUSD15000012540000.219185271
37Company E6220004EquityAUD66335724.080260.0221323111
38Settled Cash - AUD6220004CashAUD2251.9611661505.6612360.000932813
39Settled Cash - SEK6220004CashSEK38555.837753715.2942640.002301752
40Unsettled Cash - USD6220004CashUSD-737.0139544-737.0139544-0.000456614
41Settled Cash - USD6220004CashUSD7551.2687197551.2687190.004678271
42Company A6220004EquityUSD4143284416.950.176206161
43Company G6220004EquityUSD2220147918.60.09164075
44Company F6220004EquityUSD1845246528.90.15273322
45Company C6220004EquityUSD4097173303.10.107367283
46Company H6220004EquityUSD102574476.50.0461407710
47Company I6220004EquityUSD131882546.340.051140329
48Company J6220004EquityUSD5617139189.260.086232576
49Company D6220004EquityUSD7817151806.140.094049174
50Company B6220004EquityUSD1096391650.680.056780777
51Company K6220004EquitySEK501384342.217850.052252938
52Company L6220004Private EquityAUD352290248.533550.05591211
53Company E6220006EquityAUD111059809.546140.0221032211
54Settled Cash - AUD6220006CashAUD9937.5157966644.2230610.002455442
55Settled Cash - SEK6220006CashSEK64804.995236244.6996640.002307793
56Settled Cash - USD6220006CashUSD10095.211310095.21130.003730791
57Unsettled Cash - USD6220006CashUSD-1253.039908-1253.039908-0.000463074
58Company A6220006EquityUSD7282499909.30.184746511
59Company G6220006EquityUSD3687245664.810.09078795
60Company F6220006EquityUSD3091413019.420.152635482
61Company C6220006EquityUSD7441314754.30.116320623
Data_Report
Cell Formulas
RangeFormula
L12:L61L12=SUMPRODUCT((--(B12=B:B)),(--(C12=C:C)),(--(H12<H:H)))+1


This data is then pulled into an individual output sheet where we use an Index match with various criteria.

Client Reporting_MASTER_Share.xlsx
ABCDEFGHIJK
1
2
3
4Account:AU-6220013-10
5
6
7
8
9
10
11
12CompanyCurrency (LCL)QuantityMarket price (LCL)Value (USD)% of portfolio
13Company AAUD8,9560.0017.1%1
14Company FUSD3,9080.0014.5%2
15Company CSEK11,1130.0013.1%3
16Company DUSD17,6120.009.5%4
17Company JUSD12,4940.008.6%5
18Company GUSD4,0510.007.5%6
19Company BUSD25,3090.005.9%7
20Company KSEK11,1320.005.2%8
21Company IUSD2,9150.005.1%9
22Company HUSD2,2750.004.6%10
23Listed investments91.1%
24CashUSD8.9%Mutual Fund
25Total Portfolio100.0%
26
27
Client1
Cell Formulas
RangeFormula
B13:B22B13=INDEX(Data_Report!A:A,MATCH(1,INDEX((Data_Report!B:B=Client1!$J$4)*(Data_Report!L:L=Client1!J13)*(Data_Report!C:C="Equity"),,),0))
C13:C22C13=INDEX(Data_Report!D:D,MATCH(1,INDEX((Data_Report!B:B=Client1!$J$4)*(Data_Report!L:L=Client1!J13),,),0))
D13:D22D13=SUMIFS(Data_Report!$E:$E,Data_Report!$B:$B,Client1!$J$4,Data_Report!$A:$A,Client1!$B13)
E13:E22E13=SUMIFS(Data_Report!$F:$F,Data_Report!$B:$B,Client1!$J$4,Data_Report!$A:$A,Client1!$B13)
J14:J22J14=J13+1
Cells with Data Validation
CellAllowCriteria
C4List=#REF!


Many thanks in advance!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Welcome to the MrExcel board!

First thing I would try is simply to get rid of those whole column references in your SUMPRODUCT formulas as that will be a major reason for the slow calculation.
I am not sure of your actual row numbers but if it is say 217 rows by 15 clients that is only a bit over 3,000 rows so no need to force Excel to calculate over a million rows.

Try something like this. Where I have 5000 just make that big enough to cover any amount of data that you are likely to have. So if your total data is actually only about 217 rows instead of 3,000 plus then perhaps just use 1,000 instead of 5,000.

In L12, copied down.

Excel Formula:
=SUMPRODUCT((--(B12=B$12:B$5000)),(--(C12=C$12:C$5000)),(--(H12<H$12:H$5000)))+1

For me, with the sample data you provided, that change reduced the calculation time for those 50 formulas from 4.5 seconds to 0.02 seconds. That is about 225 times faster!
 
Last edited:
Upvote 0
Thank you Peter! This is sensible and very good advice, the suggested solution worked very well and will make my life a lot easier.

Out of interest, how did you determine the calculation time? Do you have a plug in for these queries?

Many thanks again.
 
Upvote 0
Thank you Peter! .. the suggested solution worked very well and will make my life a lot easier.
You're welcome. Thanks for the follow-up. :)

Out of interest, how did you determine the calculation time?
Well down this page there is a section headed "Measuring calculation time". I use something like that though I got mine from an older source that no longer exists.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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