Dynamically sum multiple columns, based on grouped criteria from another array

PrettyGood_Not Great

Board Regular
Joined
Nov 24, 2023
Messages
95
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a challenge that I am not sure exactly how to describe. The mini sheet below shows a data set that we want to SUM based on criteria. The criteria for that SUM has two elements. Element A, the headers of the data set and Element B, the headers of the return array. Element B represents a grouping of Element A and the groupings are defined in the Criteria array.

To the far right are the results if we hard code a simple addition formula. I am search for a dynamic array formula that can spill down, if possible.

I have tried using FILTER(UNIQUE()) to produce a grouping of Element A based on the Element B and tried using that as the criteria within an XLOOKUP, however I only get the first result, and this approach may be flawed to begin with, not clear.


Cell Formulas
RangeFormula
R2:T19R2=E2+J2
G4:G9,I10:I19,F12:F19,L12:L15,J3:J14,H2:H13,E2:E11,K7:K10G4=RAND()
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
How about
Fluff.xlsm
ABCDEFGHIJKLMNOP
1Criteria Array:GroupValueData Array:1020304050607080Return ArrayABC
2A100.6260.484(dynamic solution)0.6260.0000.000
3B200.1450.1580.5980.7430.0000.000
4C300.9400.9760.4770.0460.9860.0000.976
5D400.2430.8390.2890.8311.0740.0000.839
6E500.6610.6000.0960.8671.5280.0000.600
7A600.0040.4790.2760.0330.7290.0370.7290.479
8B700.7150.0560.5220.2640.8800.9780.8800.056
9C800.3320.7460.8880.1610.4910.4940.4910.746
100.1310.7140.1530.9360.1661.0670.1660.000
110.3730.4060.6690.3410.7130.0000.000
120.2680.2700.9630.6050.7990.6050.2680.799
130.3000.6190.9810.5920.6230.5920.3000.623
140.4360.4500.8280.8700.8280.4360.870
150.2610.8880.9040.0000.2610.904
160.9120.5060.0000.9120.000
170.1590.3470.0000.1590.000
180.5360.4930.0000.5360.000
190.6980.6570.0000.6980.000
Data
Cell Formulas
RangeFormula
N2:P19N2=BYROW($E$2:$L$19,LAMBDA(br,SUM(CHOOSECOLS(br,XMATCH(FILTER($C$2:$C$9,$B$2:$B$9=N1),$E$1:$L$1)))))
Dynamic array formulas.
 
Upvote 0
Solution
How about
Fluff.xlsm
ABCDEFGHIJKLMNOP
1Criteria Array:GroupValueData Array:1020304050607080Return ArrayABC
2A100.6260.484(dynamic solution)0.6260.0000.000
3B200.1450.1580.5980.7430.0000.000
4C300.9400.9760.4770.0460.9860.0000.976
5D400.2430.8390.2890.8311.0740.0000.839
6E500.6610.6000.0960.8671.5280.0000.600
7A600.0040.4790.2760.0330.7290.0370.7290.479
8B700.7150.0560.5220.2640.8800.9780.8800.056
9C800.3320.7460.8880.1610.4910.4940.4910.746
100.1310.7140.1530.9360.1661.0670.1660.000
110.3730.4060.6690.3410.7130.0000.000
120.2680.2700.9630.6050.7990.6050.2680.799
130.3000.6190.9810.5920.6230.5920.3000.623
140.4360.4500.8280.8700.8280.4360.870
150.2610.8880.9040.0000.2610.904
160.9120.5060.0000.9120.000
170.1590.3470.0000.1590.000
180.5360.4930.0000.5360.000
190.6980.6570.0000.6980.000
Data
Cell Formulas
RangeFormula
N2:P19N2=BYROW($E$2:$L$19,LAMBDA(br,SUM(CHOOSECOLS(br,XMATCH(FILTER($C$2:$C$9,$B$2:$B$9=N1),$E$1:$L$1)))))
Dynamic array formulas.
Just another day for @Fluff. WOW! that's perfect, thanks so much!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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