Get a 2D spilled formula to fulfill a distribution table matching the ranges of both dimensions

ED38

New Member
Joined
Mar 29, 2024
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have found different way to fulfill my table but none of them are manageable and future proof in the context of my file, so I am trying to get a 2D spilled formula in cell G5 that will fulfill the table without refering to intermadiate calculation in other cells (like I did in the mini sheet below).
when I try to merge the cell N5 and O5 into G5, it does not work (nested array, I guess)
Would you one of you have a solution for this?

Thanks a lot for your help.

Book1
ABCDEFGHIJKLMNOPQRSTUVW
1DISERED DISTRIBUTION TABLEInitial attempt (not spilled formula)
2123456Intermediate Spilled Formulas
3DATA SET (64)64Qty range% range0%<20%<40%<60%<80%<100%0%<20%<40%<60%<80%<100%
4Qty%10Qty rank% rank
522037,5%211151894--72151894-
622037,5%326233---72233--
710039,3%45111-2--5211-2-
810039,3%581------52-----
94339,0%6101-3----32-3---
10544,0%7126------13-----
111543,6%8252-21---23-21--
121167,0%9501------14-----
132036,4%10751------22-----
142041,8%111501------23-----
15820,0%122001------12-----
161173,0%132501------14-----
17821,0%143001------12-----
181318,2%99999999------21-----
191529,1%22
209035,7%52
2150,0%Total1827136006411
221158,0%13
2316043,8%73
241160,0%14
25517,0%11
26517,0%11
271164,0%14
283417,1%31
29533,0%12
30541,0%13
31539,0%12
322014,5%21
331013,0%11
341020,0%12
35120,0%12
36120,0%12
37826,0%12
38226,0%12
395165,9%34
405165,9%34
412034,5%22
422040,0%23
43336,0%12
4430,0%11
4530,0%11
46940,0%13
47719,0%11
48230,0%12
49530,0%12
50430,0%12
51141,0%13
52342,0%13
53218,0%11
54218,0%11
55130,0%12
56231,0%12
57140,0%13
58243,0%13
59244,0%13
6017,0%11
6110,0%11
62331,0%12
63115,0%11
64117,0%11
65118,0%11
66115,0%11
67120,0%12
68130,0%12
Sheet1
Cell Formulas
RangeFormula
G2:L2G2=COLUMN(OFFSET($G$3:$L$3,0,0,6,))-COLUMN($G$3)+1
D4:D17D4=ROW(OFFSET(E4:E17,0,0,14,))-ROW($E$4)+1
G5:L18G5=COUNTIFS(O5#,"="&$G$2:$L$2,N5#,"="&$D$4:$D$17)
N5:N68N5=MATCH($A$5:$A$68,$E$4:$E$17+1,1)
O5:O68O5=MATCH($B$5:$B$68,$G$3:$L$3-0.0000001,1)
S5:W18S5=COUNTIFS(OFFSET($A$5,0,0,$B$3,),"<="&$E5,OFFSET($B$5,0,0,$B$3,),"<"&S$3)-SUM($R5:R5)-SUM($R$4:S4)
G21:L21G21=SUM(G5:G18)
M21M21=SUM(G21:L21)
Dynamic array formulas.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
How about
Fluff.xlsm
ABCDEFGHIJKLM
1DISERED DISTRIBUTION TABLE
2123456
3DATA SET (64)64Qty range% range00.20.40.60.81
4Qty%10
52200.37521115189400
62200.375326233000
71000.39285714451110200
81000.39285714581000000
9430.39024396101030000
1050.447126000000
11150.436363648252021000
12110.679501000000
13200.3636363610751000000
14200.41818182111501000000
1580.2122001000000
16110.73132501000000
1780.21143001000000
18130.1818181899999999000000
19150.29090909
20900.35714286
2150Total18271360064
22110.58
231600.4375
24110.6
2550.17
2650.17
27110.64
28340.17073171
2950.33
3050.41
3150.39
32200.14545455
33100.13
34100.2
3510.2
3610.2
3780.26
3820.26
39510.65853659
40510.65853659
41200.34545455
42200.4
4330.36
4430
4530
4690.4
4770.19
4820.3
4950.3
5040.3
5110.41
5230.42
5320.18
5420.18
5510.3
5620.31
5710.4
5820.43
5920.44
6010.07
6110
6230.31
6310.15
6410.17
6510.18
6610.15
6710.2
6810.3
Sheet6
Cell Formulas
RangeFormula
G2:L2G2=SEQUENCE(,COLUMNS($G$3:$L$3))
D4:D17D4=SEQUENCE(ROWS(E4:E17))
G5:L18G5=LET(a,XMATCH(A5:A68,E4:E17+1,-1),b,XMATCH(B5:B68,G3:L3-0.0000001,-1),MAKEARRAY(ROWS(D4#),COLUMNS(G2#),LAMBDA(r,c,SUM((a=r)*(b=c)))))
G21:L21G21=SUM(G5:G18)
M21M21=SUM(G21:L21)
Dynamic array formulas.
 
Upvote 0
Solution
Thanks a lot Fluff, that answers the point and on top, as I wanted to avoid the ranges with the ranking (1,2 ,3,...) on both sides, the sequence formula your suggested allows to include that within a single formula I attached below as a final solution.

Great thanks to you

Book1
ABCDEFGHIJKL
1DISERED DISTRIBUTION TABLE
2
3DATA SET (64)64Qty range% range0%20%40%60%80%100%
4Qty%0
52200,3751115189400
62200,37526233000
71000,39285751110200
81000,39285781000000
9430,390244101030000
1050,44126000000
11150,436364252021000
12110,67501000000
13200,363636751000000
14200,4181821501000000
1580,22001000000
16110,732501000000
1780,213001000000
18130,18181899999999000000
19150,290909
20900,357143
2150
Sheet2
Cell Formulas
RangeFormula
G5:L18G5=LET(a,XMATCH(A5:A68,E4:E17+1,-1),b,XMATCH(B5:B68,G3:L3-0.0000001,-1),MAKEARRAY(ROWS(SEQUENCE(ROWS($E$4:$E$17))),COLUMNS(SEQUENCE(,COLUMNS($G$3:$L$3))),LAMBDA(r,c,SUM((a=r)*(b=c)))))
Dynamic array formulas.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,802
Messages
6,181,054
Members
453,014
Latest member
Chris258

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