ASCAN

ASCAN(a,[d])
a
array
[d]
direction argument ; 0 or omitted scan by array, -1 by rows, 1 by clms

Array SCAN, 3 in 1 function, SCAN by row, by column, by array

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
832
Office Version
  1. 365
Platform
  1. Windows
ASCAN, Array SCAN, 3 in 1 function, SCAN by row, by column, by array. This is my take of tboulden's SCANBYROW/BYCOL.
Uses only new!! SCAN lambda helper function, no need of byrow,bycol,makearray, or lambda as arguments.
Excel Formula:
=LAMBDA(a,[d],
    LET(y,IF(d=1,TRANSPOSE(a),a),s,SCAN(0,y,LAMBDA(v,a,v+a)),r,ROWS(s),c,COLUMNS(s),sr,SEQUENCE(r)-1,
       x,s-IF(d,IFERROR(INDEX(INDEX(s,,c),sr)*sr^0,0),0),
       IF(d=1,TRANSPOSE(x),x)
   )
)
LAMBDA 1.1.3.xlsx
ABCDEFGHIJKLMNOPQRST
1d,omitted (by array)d,-1 (by rows)d,1 (by clms)
2sample 1a=ASCAN(A3:D6)=ASCAN(A3:D6,-1)=ASCAN(A3:D6,1)
3123413610136101234
45678152128365111826681012
5910111245556678919304215182124
613141516911051201361327425828323640
7
8d,omitted (by array)d,-1 (by rows)d,1 (by clms)
9sample 2a=ASCAN(A10#)=ASCAN(A10#,-1)=ASCAN(A10#,1)
10123413610136101234
115678152128365111826681012
12910111245556678919304215182124
1313141516911051201361327425828323640
14171819201531711902101735547445505560
15212223242312532763002143669066727884
16
17Note: Did not set an extra argument for any kind of "initial value", since the only thing it does is too simple,
18adds a constant value to the final outcome , like in 10+ASCAN(a)
19
ASCAN post
Cell Formulas
RangeFormula
F2,P9,K9,F9,P2,K2F2=FORMULATEXT(F3)
F3:I6F3=ASCAN(A3:D6)
K3:N6K3=ASCAN(A3:D6,-1)
P3:S6P3=ASCAN(A3:D6,1)
A10:D15A10=SEQUENCE(6,4)
F10:I15F10=ASCAN(A10#)
K10:N15K10=ASCAN(A10#,-1)
P10:S15P10=ASCAN(A10#,1)
Dynamic array formulas.
 
Upvote 0
Hi Bill,
Something is wrong with the input data.
As reference, my formulas work with indexes (k) instead of text strings. Since there are unique names there is unique correspondence btw sorted names and seq(146). We can both use this as common reference.
Got your data, used XMATCH for the distrib of indexes and checked with my DS (function that calculates the consecutive distances of a sequence of indexes) and
got a total route of 96550 not 76326. That distance is bigger than the worst distance I got using the non cluster method (MK)
Then I checked the names, everything was ok, then I realized that your Lat and Lon clms are inversed. Can you check how your distances were calculated?
From Wiki Great Wall coord: "Latitude and longitude coordinates are: 40.431908, 116.570374."
Here is the data (hope that mini-sheet will get it entirely.
Book2.xlsx
ABCDEFGHIJKL
1Bill's data=XMATCH(B3:B148,TAKE(pl,,1))
2IDLocationLatLonDistance↓↓=DS(G3#)
31Great Wall of China, China116.570440.4319400=DS(G3#,1)
41Gungnamji Pond, Republic of Korea126.912236.26932729.875741629.172696550.27
51Mount Fuji, Japan138.731935.3606817.600485664.6623
61Uzon Caldera, Russia159.915654.511671844.5491291666.471check
72Matanuska Glacier, Alaska-148.90961.773567.842751877.88=SUM(I:I)
82Wedgemount Lake, British Columbia, Canada-122.88250.14521882.1281391272.68396550.27
92Mount Shuksan, North Cascades National Park-121.77948.825290.4611687103.7521
102Tom **** & Harry Mountain, Oregon-121.74345.3345126.9405127241.1439
115Clear Lake, Oregon-121.9744.504934.064012158.37273
125Crater Lake, Oregon-122.13342.9358.8231525109.0986
135Sonora Peak, California-119.5538.18245.1277113354.9908
146Mirror Lake, Yosemite National Park, California-119.5537.745714.796257930.0015
156Taft Point, Yosemite National Park, California-119.59437.71743.1560721153.077359
169Vasquez Rocks Natural Area Park, California-118.31334.4908139.4993132234.0639
179Racetrack Playa, Death Valley, California-117.55436.716789.08942102159.5652
189Badwater Basin, Death Valley, California-116.84136.23951.550981051.57622
199Waterton Lake, Alberta, Canada-113.91549.06428.9485138897.8817
2010Palisades Beach, Grand Canyon National Park, Arizona-112.8636.0978362.116194897.0111
2111Lake Powell, Hite Overlook-110.73137.388150.780764147.7788
2212Lake Powell, Escalante River-110.63713.076366327.75128
2313Monument Valley Navajo Tribal Park, Arizona-110.20436.998627.383388221.86973
2413Warren Canyon, Utah-110.08438.659940.37035137114.9471
2515Abajo Peak, Utah-109.38337.880951.72286165.88887
2615Maroon Lake, Aspen, Colorado-106.94939.0988170.213674156.2236
2715Mirror Lake, Wyoming-106.31941.338262.0404878158.2161
2816Dunas De Bilbao, Mexico-102.86926.0094355.8736301077.08
2917White Sands, New Mexico-106.17132.7872256.1869142508.5571
3017Playa El Requesón, Mexico-111.83226.63762414.263599543.6626
3117Motu Rimatiai, Tetiaroa-149.535-17.00153133.621833934.874
3217Matavai Bay, Tahiti, French Polynesia-149.6-17.559433.5327638.77756
3318Ahu Tongariki, Rapa Nui (Easter Island)-109.168-27.11262816.93222654.183
3418Isabela Island, Galápagos-91.417-0.81237.116472165.585
3519Chichen Itza, Yucatán State, Mexico-88.568620.684193.3192201496.558
3620Parque Nacional Palo Verde, Costa Rica-85.327610.4094226.161696741.7176
3721Crego Park Lake, Lansing, Michigan-84.557742.7518200.9703262234.7
3821Mural de la Prehistoria, Viñales, Cuba-83.700822.6167153.0801881391.807
3924Islote Sucre (Johnny Cay), Colombia-81.689512.5999163.951749704.4787
4026Machu Picchu, Peru-72.545-13.1631731.2635711886.707
4127Vinicunca, Peru (Rainbow Mountain)-71.4042-13.849680.1599513490.11446
4228Atacama Desert, Chile-70-24250.82798707.1482
4330Laguna Santa Rosa, Nevado Tres Cruces National Park, Chile-69.766-27.225678.3142757223.3009
4430El Chaltén, Los Glaciares National Park, Argentina-72.9131-49524.2322311513.538
4530Rio De Las Vueltas, Argentina-72.8577-49.33957.89177910423.58581
4631Laguna Torre, Santa Cruz Province, Argentina-73.0726-49.28814.881865810.31109
4732Salar de Uyuni, Bolivia-67.5-20.1333769.56081072037.401
4836Cayo Muerto, Venezuela-68.260510.92978801.1134192146.464
4936Lencois Maranhenses, Brazil-42.8333-2.53331824.11661979.668
5037Namib Desert, Namibia15-244220.958894127.145
5139Cape of Good Hope, South Africa18.4174-34702.306816720.8518
5241Golden Gate Highlands, South Africa28.58-28.5219782.803438708.8748
5341Bell Park Pier, South Africa29.43389-28.958864.622931259.88166
5442Mafia Island Marine Park, Tanzania39.755-7.91111387.895721601.418
5543Erta Ale Volcano, Ethiopia40.5213.61134.45321486.916
5645Forgotten Pyramids, Meroë, Sudan33.7477716.93627502.504435506.6696
5745The Great Temple of Ramesses II, Abu Simbel, Egypt31.632822.336346.1956120397.5617
5846The Temple of Horus at Edfu, Egypt32.87424.9759176.4479123198.5529
5946Court of Amenhotep III, Luxor Temple, Egypt32.657225.699144.599532351.75995
6049Wadi Rum, Jordan35.425929.5349291.1423136314.504
6150The Monastery Ad Deir, Petra35.444230.325144.4939712254.59811
6251Dead Sea, Wadi Mujib, Jordan35.531.566.210292781.22959
6352Jebel El Tih, Egypt33.5366729.14778190.564250200.2625
6452Funerary Complex of Djoser, Egypt31.215229.8715165.83136148.2438
6552Baharyia Oasis Salt Lake, Eqypt28.93228.352182.004911173.2164
6655White Desert National Park (Sahara el Beyda), Egypt28.4528.574435.9206914133.05862
6755Pamukkale, Turkey29.121737.9222567.696995646.9063
6855Malyovishki Lakes, Bulgaria23.3158842.19838480.596373425.8137
6957Varlaam Monastery, Meteora, Greece21.628639.7212196.4368131192.4239
7059Sahara Desert, Algeria9.79927624.69471288.9611061244.615
7160Great Pyramid Of Giza, Egypt31.134329.97921512.349391356.811
7260Deryouk Plain, Iran52.056136.08111477.979291279.787
7360Harireh Historical City, Kish, Iran53.9926.5437417.814342668.6105
7463The Lut Desert, Iran58.529.5331.4927121342.5012
7565Tang Mud Volcano, Iran59.9329825.46699173.5336117292.1041
7665Yenkit Beach, Oman58.7047323.6152107.0415144149.3997
7765Lake Bucura, Retezat Mountains, Romania22.916745.36672694.287612498.73
7866Monte Piana, Italy12.346.5822737.740781516.1575
7968The Dolomites, Italy11.913946.434628.4741311920.99846
8068Hörnle Mountain, Germany10.66847.677120.377744103.9398
8169Alblittkopf Mountain, Austria10.3385547.0846446.22499443.72553
8271Julier Pass, Switzerland9.7946.447857.552055351.07941
8372Mittelgipfel, Bernese Alps, Switzerland8.01946.571122.62958084.62657
8473Col Du Lautaret, Hautes-Alpes, France6.407245.0333153.304722131.5563
8574Lac Lérié, Plateau d'Emparis, France6.345.05117.505549565.37508
8675Dent de Crolles from La Pravouta, France5.87245.320634.883592827.9435
8776Aiguestortes National Park, Spain0.9942.6385.88883306.9104
8876Lac de Peyrelade, Hautes-Pyrénées, France0.11247242.942865.080455550.40737
8978Port Esportiu de Calafat, Spain0.867840.9234148.9336100144.7983
9079Cala Tuent Mallorca, Spain2.78639.85151.825514125.2359
9180Todra Gorge, Morocco-5.585931.5944811.7471126737.9588
9281Ursa Beach, Portugal-9.482438.7794560.7745128542.756
9382Llyn Idwall, Wales, United Kingdom-3.938653.081052.809681022.395
9482High Cup Nick, England-2.457954.648148.856243123.9736
9584Loch Grannoch, Scotland-4.1555.119121.31957074.69593
9684Glencoe, Scotland-5.0156.6822122.946537113.0034
9786Loch Coruisk, Scotland-6.14857.286.298146955.84199
9887Isle of Skye, Scotland-6.257.535923.347424823.28473
9988Vestrahorn, Iceland-16.651264.2437852.5727133579.9279
10089Skaftafell Glacier, Iceland-16.999364.016728.3468711118.86758
10189Jokulsarlon Glacier Lagoon, Iceland-17.193164.049113.55758526.274645
10289Virkisfell, Iceland-16.664.7333361.0251213550.47485
10390Hverfjall Volcano Crater, Iceland-16.88865.64363.379014563.39189
10491Thorsmork, South Highlands of Iceland-19.439263.67218.6936125155.7507
10593Þingvellir (Thingvellir) National Park, Iceland-21.076464.28217119.857112465.19452
10694Blue Lagoon, Iceland-22.01763.880669.908991339.69906
10795Snæfellsjökull Volcano, Iceland-23.7864.8135.111311282.54712
10896Kulusuk, Greenland-37.197465.56742927.987554391.8444
10997Ililissat Icefjord - Greenland-19.309871.897781293.43746621.6724
11098Eysturoy, Faroe Islands-6.862.151084.00433749.6623
11198Finnøya, Norway6.51320562.79961920.767234426.6057
11299Ytresand Beach, Norway13.1347868.09911582.4018145411.9637
113100Sennesvik, Norway13.7096968.1080539.7198310814.82384
114100Andenes, Norway16.1136969.31923184.70066103.1101
115101Nordenskjold Glacier, Svalbard15.1195577.9091575.548990593.6849
116102Nuorgam, Finland27.8716670.083081013.63691589.5812
117103Lake Kel Suu, Kyrgyzstan76.3899840.70083490.883622649.628
118104Taj Mahal, Yamuna River, India78.041927.1751235.3833116939.0888
119105Vabbinfaru Island, North Malé Atoll, Republic of Maldives73.45274.27496.54541301610.966
120107Ameenpur, Telangana, India78.319617.5401.31325971.4581
121108Sibinskie Lakes, Kazakhstan82.6232649.43387460.25771102219.048
122108Path to Everest, Nepal, Himalayas86.92528.0014321.3165971497.982
123109Rongbuk Glacier, Mt. Everest, Tibet86.93280.345441050.319936
124111Lhoknga Beach, Indonesia95.345.5321570.6342671647.205
125115Yuanyang Rice Terraces, China102.723.12537.17251461310.165
126116Jiuzhaigou Valley, China103.913633.2180.554751700.2207
127117Orkhon Valley, Mongolia103.846746.8625225.952593943.8136
128118Lake Baikal Sunset, Russia107.80553.16296297.709760469.1876
129118Xe Bang Fai River, Laos105.9918.718692.57571432381.455
130120Tengger Caldera Volcano, Indonesia112.95-7.94768.42511181901.611
131121Cathedral Gorge, Australia128.3727-17.48051114.144181229.346
132123Raja Ampat Island, New Guinea130.8547-0.5765.43041031185.081
133125Port Olry, Vanuatu167.2-15.46672651.8681012685.041
134126Plage de Ouano - New Caledonia165-21400.932798408.5611
135127South Piha Beach, New Zealand174.4744-36.95451265.4371141240.275
136128Auroa Point, New Zealand177.9018-39.0715278.10279236.9954
137129Mount Ruapehu, New Zealand175.5636-39.28162.162786126.0375
138130Wharariki Beach, Nelson, New Zealand172.8065-40.53208.9346140169.7012
139131Onetahua, New Zealand (Farewell Spit)172.734-40.55945.39839924.313811
140131Lake Rotoiti, New Zealand172.8373-41.81586.343436586.90091
141134Lake Angelus, New Zealand173.056-41.986219.134575916.32192
142134Castle Hill, New Zealand172.7613-43.251689.102051788.68822
143134Craigieburn Range, Southern Alps, New Zealand171.7667-43.1868.881682450.31574
144136Mount Binser, Arthur's Pass National Park, New Zealand171.701-42.953816.115868415.97383
145136Aoraki / Mount Cook, Southern Alps, New Zealand170.15-43.7344119.6451794.75602
146138Shotover River, Queenstown, New Zealand168.693-45.0294133.6527109114.7883
147139Milford Sound, The South Island of New Zealand167.9259-44.641659.129297746.14909
148140Cape Evans, Ross Island, Antarctica168.515-76.78292172.71152220.388
149
Sheet7
Cell Formulas
RangeFormula
G1G1=FORMULATEXT(G3)
G3:G148G3=XMATCH(B3:B148,TAKE(pl,,1))
I2,K7,K3I2=FORMULATEXT(I3)
I3:I148I3=DS(G3#)
K4K4=DS(G3#,1)
K8K8=SUM(I:I)
Dynamic array formulas.
Named Ranges
NameRefers ToCells
pl=Sheet1!$B$2:$D$147G3, I3, K4
 
I have checked if both our distance calculation formulas are consistent, and they are.
I know that because I have switched lat and long columns, to my input data, like you did, and my distance function returned the exact value like yours.
=> the small data is obtained with the columns switched ✌️
It will be very interesting to run Solver again for the proper data set and compare the results. 😉
All data I got so far (from top to bottom, all values (mini-sheet was great to take it all)
Book2.xlsx
ABCDEFGHIJKLM
1MK method, minimum distance methodCK method, cluster method
2for each indx total distfor each indx total distbest route CK method
3in asc. orderbest route MK methodin asc. order=CK(15,300,1)
4=MC()=MK(77,,1)=MC(,1,300)1583274.89
57787570.877701583274.889610
610987582.8210946.14909284635.89373219.7705
710387619.997114.7883884635.893131192.4239
81887726.12489.6574210784635.89395421.8409
94787733.628415.973838484793.45839560.6473
106287761.31757.298672484816.366368.87761
111787808.295988.68822784921.2950148.2438
126587855.176516.321927784983.026136116.8656
1314087938.389286.9009110985026.50912254.59811
149287940.261404.3138115785055.6692781.22959
157587957.4486169.70122085151.08411449.2174
16987963.379126.03755485151.08414133.05862
174087964.18114236.99548885151.08423326.0616
1811488023.43981240.27511285151.08412351.75995
198688063.52101408.561112785151.084120198.5529
203588275.36182571.55913985151.08435397.5617
215988361.611031185.08112485343.20832506.6696
228488396.221181335.4561385358.53421248.356
232488403.2671529.21310285668.402121342.5012
24788520.411431159.4913285692.251117292.1041
2511888761.44146370.81819585867.571144149.3997
26288816.4151700.2207185923.25729948.1424
2710488929.1640858.5219586042.728621350.888
285888931.5841629.17264086042.728110675.0347
293188952.0985664.66235186042.72893990.7464
3010189283.61291666.4716086042.72860469.1876
315189517.56751877.886286042.72840970.5594
3212689543.481391272.6837586042.72841629.1726
339889593.3287103.75219386042.72885664.6623
3412889712.73127241.143914486042.7281291666.471
3510689734.52158.372732686065.454751877.88
366789850.9125109.09867486065.4541391272.683
379190058.86113354.99082586219.60887103.7521
3810590131.417930.00158586355.144127241.1439
399790131.711153.07735912986355.1442158.37273
408990239.91102131.7834186387.23825109.0986
411590253.221051.576224286387.238138578.0349
4213090353.58132146.511810586387.238113802.1158
4311690371.4694326.817811686387.2387930.0015
442590544.163140.060711786387.2381153.077359
451290616.668221.8697312186387.238102131.783
4614390621.846439.559239786387.7761051.57622
473890643.7181.194248086857.278132146.5118
489090728.1813765.888873386863.64194326.8178
4913890760.9574171.32413486863.64163140.0607
501690850.8978158.21614686863.6418221.86973
5113290899.24142590.760313586863.6416439.55923
5214690930.2430508.557114586863.641181.19424
5310291000.4899556.534710886881.43113765.88887
545791239.53201525.7072986895.37474171.3241
5513791308.5188339.83565386914.03678158.2161
56591322.4449704.47878186933.753142590.7603
57191339.6496289.028812086960.92130508.5571
586091396.4847880.19863186987.86399556.5347
597191397.41711548.174786987.863201525.707
60891438.613490.114467186987.86388339.8356
6111091463.89107504.841110486998.6449704.4787
6213491478.378311.36745886998.80896289.0288
637491490.2457223.30094587036.97447880.1986
644591570.13311513.538687075.909711548.17
659391592.785821.1604512587140.71913490.11446
667891602.4310410.311096787158.67107504.8411
679591630.6322459.43111087158.678311.3674
684191661.21762654.18311187158.6757223.3009
6910791664.728338.7775613087158.67311513.538
701391695.33154381.85814387158.675821.16045
7112491710.15164674.13414687158.6710410.31109
725291735.4238708.874813487158.92922459.431
7311191737.691259.881665287162.653762654.183
7413391752.0389955.08119087168.228338.77756
759491753.79721978.1713387168.221012865.815
762791800.42321486.9169887187.36798408.5611
7713691883.8135506.669610187187.367771641.691
783491902.61120397.561713787343.1927126.7401
7914191916.85123198.55291487345.0292489.65742
801191925.142351.759954987395.318415.97383
815091930.4450244.2599187401.1131757.29867
826491943.63136116.86562887427.5745988.68822
838291949.0712254.598114387427.5746516.32192
846391960.882781.229595587442.9569286.90091
8512292023.4236278.26978387443.1771404.313811
862692069.48398.87761387444.02986169.7012
876892223.6411174.01382287461.9279126.0375
8812092264.3414133.058625687462.66114236.9954
894392311.1795646.90637687462.66109633.6432
9011392325.26131421.840910687462.66152193.54
9111592342.4673192.423912687462.66184329.153
927992344.5161219.770512887462.661031185.081
937092363.0881516.15757387515.5281181335.456
941092443.7711920.998461987537.01671529.213
9511792484.73487.028663087537.011431159.49
9614492499.314443.725536687537.01146370.8181
9712192514.455394.429918287537.0151700.2207
981492534.398084.626579987537.011051070.255
994892539.522131.556314287537.01970.319936
1006992557.62565.375081087563.152116546.7356
1013792610.982827.94356387563.1525668.5918
1025592614.23306.91046487570.81130971.4581
1036192621.745550.407374487596.514722469.96
104392643.01100144.798310087615.152381599.065
1052992666.7514125.235911387617.8371259.88166
10610092743.57128659.322111587627.97516735.9147
1074292778.84126542.7567987628.22589720.8518
1082892847.461061049.8862787633.0591063381.804
1092292850.42682087.14212287633.0591261049.886
1105692855.2343123.97366187638.756128542.756
1114493044.027074.69593487652.249100568.1451
1128193064.7937113.00349487702.5083115.9907
11311993076.746955.841994887731.6975550.40737
114493087.374823.284736887759.10914254.6058
1155393156.9933319.41846987773.09628409.1247
1168093209.97133338.77277087778.3555627.9435
1173993216.9311118.8675813887788.242225.37508
1183693224.03526.27464511987809.34780131.5563
1193293271.113550.4748514187824.0135384.62657
12012993303.954563.3918913687826.922451.07941
1212093343.51124154.32288787843.4144443.72553
1228893359.251339.699061187846.599119103.9398
12312793432.1712580.017645087847.7558120.99846
1248593443.89112151.884813187849.645691069.045
1252193490.2954391.84443787866.6383755.84199
1269993492.3146621.67243987896.51970113.0034
12713993642.9890728.69313687911.8814374.69593
1288393683.5891589.58122187959.1468123.9736
1297693713.576286.2045988081.45748320.3523
1308793738.33108103.11017888108.23133319.4184
13113193746.2914514.823842388141.19534426.6057
1327393921.9734411.96379688175.115145411.9637
1331993981.15292660.0346588210.26410814.82384
13414593993.52121588.497712388221.0216103.1101
13510894003.02117292.10411288281.08191286.204
1364694032.36144149.3997988305.76890589.5812
13714294051.7942357.63611688305.76846728.6931
138694094.441161480.6391888305.768112503.0422
1393394095.1997546.73563288305.7681382.54712
1402394128.171050.3199363888305.76812439.69906
1413094153.865908.64417288305.76812565.19452
14212394170.76130971.45818988305.7685273.19948
1439694182.78622523.25710388305.7681116.274645
14411294278.23110675.034711888305.76813318.86758
14512594408.0993990.746414088357.96313533.85822
14613594422.5860469.18769288364.1544563.39189
1474994470.111384964.08911488471.31954576.963
1485494578.15261466.3448688523.674262385.739
1497294719.08192406.9611788664.456192406.961
1506695959.65661979.6683588906.393661979.668
151
Sheet6
Cell Formulas
RangeFormula
K3,B4,H4,E4K3=FORMULATEXT(K4)
K4:L150K4=CK(15,300,1)
B5:C150B5=MC()
E5:F150E5=MK(77,,1)
H5:I150H5=MC(,1,300)
Dynamic array formulas.
Named Ranges
NameRefers ToCells
pl=Sheet1!$B$2:$D$147B5, E5, H5, K4
 
ABYROW.xlsx
ABCDEFGHIJKLMNOPQRS
1Moving Average , different approach, unpivoting, using BYROW and ABYROW
2
3=LET(a,C5:C35,nm,6,r,ROWS(a)-nm+1,s,SEQUENCE(,nm)+SEQUENCE(r)-1,x,INDEX(a,s),BYROW(x,LAMBDA(a,AVERAGE(a))))
4Month EndSales=LET(a,C5:C35,nm,6,ABYROW(SEQUENCE(ROWS(a)-nm+1),LAMBDA(i,AVERAGE(INDEX(a,SEQUENCE(,6)+i-1)))))
531-07-22614,212494,631494,631
630-06-22551,250456,528456,528To prove that ABYROW is "natively" capable (BYROW is not)
731-05-22352,220410,297410,297to "spread" (spill) a horizontal pattern from a vertical array (single values/row).
830-04-22607,028405,090405,090ABYROW is can embed a pattern created from a column.
931-03-22494,401342,149342,149=ABYROW(SEQUENCE(26),LAMBDA(i,SEQUENCE(,6)+i-1))
1028-02-22348,672283,648283,648123456
1131-01-22385,596273,681273,681234567
1231-12-21273,864279,941279,941345678
1330-11-21320,980282,871282,871456789
1431-10-21229,383328,734328,7345678910
1530-09-21143,395337,529337,52967891011
1631-08-21288,865394,946394,946789101112
1731-07-21423,159393,964393,9648910111213
1830-06-21291,445385,404385,40491011121314
1931-05-21596,158366,708366,708101112131415
2030-04-21282,149314,443314,443111213141516
2131-03-21487,897358,810358,810121314151617
2228-02-21282,977315,192315,192131415161718
2331-01-21371,800307,968307,968141516171819
2431-12-20179,265289,454289,454151617181920
2530-11-20282,570282,478282,478161718192021
2631-10-20548,348268,041268,041171819202122
2730-09-20226,192219,677219,677181920212223
2831-08-20239,634260,147260,147192021222324
2931-07-20260,717295,960295,960202122232425
3030-06-20137,409278,240278,240212223242526
3131-05-20195,947222324252627
3230-04-20258,165232425262728
3331-03-20469,009242526272829
3429-02-20454,513252627282930
3531-01-20154,396262728293031
36
mov avrg 2
Cell Formulas
RangeFormula
E3E3=FORMULATEXT(E5)
G4,I9G4=FORMULATEXT(G5)
E5:E30E5=LET(a,C5:C35,nm,6,r,ROWS(a)-nm+1,s,SEQUENCE(,nm)+SEQUENCE(r)-1,x,INDEX(a,s),BYROW(x,LAMBDA(a,AVERAGE(a))))
G5:G30G5=LET(a,C5:C35,nm,6,ABYROW(SEQUENCE(ROWS(a)-nm+1),LAMBDA(i,AVERAGE(INDEX(a,SEQUENCE(,6)+i-1)))))
I10:N35I10=ABYROW(SEQUENCE(26),LAMBDA(i,SEQUENCE(,6)+i-1))
Dynamic array formulas.
Xlambda, I am going through this old post one message at a time, clicking the thumbs ups (which I never noticed before), and I ran into this spilled moving average post. So I immediately tried to do it. Then, because I have not been using Excel for almost 5 months, I am so rusty that it took me over 2 hours to come up with a formula lol*100 Here is what I imagined:

=LET(v,C5:C35,b,7,rs,ROWS(v),s,SEQUENCE(rs),IF(s<b,"",MAP(s,LAMBDA(r,AVERAGE(INDEX(v,SEQUENCE(b,,r-G1+1)))))))

after two hours, I can now move on to the next post...
 
Hi Mike, the Excel Legend Himself. You are not rusty at all; you came back like a storm. I am so unimaginably honored to have you here. But these are sooooo old.
Today we can solve any of those old tasks only with 3 functions,
I think that for the last 3 years, every YT you've made, that implied formulas, has a study posted around here on a thread. 😊
What is amazing and nostalgic, is that after all the experience accumulated these years, to solve this, I will still use the "pivot" concept to this day.😉
=LET(v,C3:C33,n,6,BYROW(INDEX(v,SEQUENCE(ROWS(v)-n+1)+SEQUENCE(,n)-1),AVERAGE))
Book1
ABCDEFGHIJKLMNOPQRSTUVW
1single cell formula
2Month EndSales=LET(v,C3:C33,n,6,BYROW(INDEX(v,SEQUENCE(ROWS(v)-n+1)+SEQUENCE(,n)-1),AVERAGE))
331-07-22614212494630.5
430-06-22551250456527.8Concept: Moving average for n=6 elements for a clm vector that has r rows 3 steps
531-05-22352220410296.8
630-04-22607028405090.2creating the index pattern n=6, r=rows(c3:c33)=31
731-03-22494401342149.3 =seq(r-n+1)+seq(,n)-1
828-02-22348672283648.3extracting values
931-01-22385596273680.5=SEQUENCE(26)+SEQUENCE(,6)-1=INDEX(C3:C33,G10#)=BYROW(N10#,AVERAGE)
1031-12-21273864279941123456614212551250352220607028494401348672494630.5
1130-11-21320980282871.2234567551250352220607028494401348672385596456527.8
1231-10-21229383328734.2345678352220607028494401348672385596273864410296.8
1330-09-21143395337528.5456789607028494401348672385596273864320980405090.2
1431-08-21288865394945.55678910494401348672385596273864320980229383342149.3
1531-07-21423159393964.267891011348672385596273864320980229383143395283648.3
1630-06-21291445385404.3789101112385596273864320980229383143395288865273680.5
1731-05-21596158366707.78910111213273864320980229383143395288865423159279941
1830-04-2128214931444391011121314320980229383143395288865423159291445282871.2
1931-03-21487897358809.5101112131415229383143395288865423159291445596158328734.2
2028-02-21282977315192111213141516143395288865423159291445596158282149337528.5
2131-01-21371800307968.2121314151617288865423159291445596158282149487897394945.5
2231-12-20179265289454.3131415161718423159291445596158282149487897282977393964.2
2330-11-20282570282478.3141516171819291445596158282149487897282977371800385404.3
2431-10-20548348268041.2151617181920596158282149487897282977371800179265366707.7
2530-09-20226192219677.3161718192021282149487897282977371800179265282570314443
2631-08-20239634260146.8171819202122487897282977371800179265282570548348358809.5
2731-07-20260717295960181920212223282977371800179265282570548348226192315192
2830-06-20137409278239.8192021222324371800179265282570548348226192239634307968.2
2931-05-20195947202122232425179265282570548348226192239634260717289454.3
3030-04-20258165212223242526282570548348226192239634260717137409282478.3
3131-03-20469009222324252627548348226192239634260717137409195947268041.2
3229-02-20454513232425262728226192239634260717137409195947258165219677.3
3331-01-20154396242526272829239634260717137409195947258165469009260146.8
34252627282930260717137409195947258165469009454513295960
35262728293031137409195947258165469009454513154396278239.8
36
Sheet1
Cell Formulas
RangeFormula
E2,U9,N9,G9E2=FORMULATEXT(E3)
E3:E28E3=LET(v,C3:C33,n,6,BYROW(INDEX(v,SEQUENCE(ROWS(v)-n+1)+SEQUENCE(,n)-1),AVERAGE))
G10:L35G10=SEQUENCE(26)+SEQUENCE(,6)-1
N10:S35N10=INDEX(C3:C33,G10#)
U10:U35U10=BYROW(N10#,AVERAGE)
Dynamic array formulas.
 
And this is with MAP alternative , (your concept) 😉
byrow/map
=LET(v,C3:C33,n,6,BYROW(INDEX(v,SEQUENCE(ROWS(v)-n+1)+SEQUENCE(,n)-1),AVERAGE))
=LET(v,C3:C33,n,6,MAP(SEQUENCE(ROWS(v)-n+1),LAMBDA(x,AVERAGE(INDEX(v,SEQUENCE(n,,x))))))
Book1
ABCDEFGHIJKLMNOPQR
1single cell formula
2Month EndSales=LET(v,C3:C33,n,6,BYROW(INDEX(v,SEQUENCE(ROWS(v)-n+1)+SEQUENCE(,n)-1),AVERAGE))
331-07-22614212494630.5
430-06-22551250456527.8=LET(v,C3:C33,n,6,MAP(SEQUENCE(ROWS(v)-n+1),LAMBDA(x,AVERAGE(INDEX(v,SEQUENCE(n,,x))))))
531-05-22352220410296.8494630.5
630-04-22607028405090.2456527.8
731-03-22494401342149.3410296.8
828-02-22348672283648.3405090.2
931-01-22385596273680.5342149.3
1031-12-21273864279941283648.3
1130-11-21320980282871.2273680.5
1231-10-21229383328734.2279941
1330-09-21143395337528.5282871.2
1431-08-21288865394945.5328734.2
1531-07-21423159393964.2337528.5
1630-06-21291445385404.3394945.5
1731-05-21596158366707.7393964.2
1830-04-21282149314443385404.3
1931-03-21487897358809.5366707.7
2028-02-21282977315192314443
2131-01-21371800307968.2358809.5
2231-12-20179265289454.3315192
2330-11-20282570282478.3307968.2
2431-10-20548348268041.2289454.3
2530-09-20226192219677.3282478.3
2631-08-20239634260146.8268041.2
2731-07-20260717295960219677.3
2830-06-20137409278239.8260146.8
2931-05-20195947295960
3030-04-20258165278239.8
3131-03-20469009
3229-02-20454513
3331-01-20154396
34
Sheet1
Cell Formulas
RangeFormula
E2,G4E2=FORMULATEXT(E3)
E3:E28E3=LET(v,C3:C33,n,6,BYROW(INDEX(v,SEQUENCE(ROWS(v)-n+1)+SEQUENCE(,n)-1),AVERAGE))
G5:G30G5=LET(v,C3:C33,n,6,MAP(SEQUENCE(ROWS(v)-n+1),LAMBDA(x,AVERAGE(INDEX(v,SEQUENCE(n,,x))))))
Dynamic array formulas.
 
Thanks for the reply back. Of course: Eta Lambdas : ) : ) : ) I can't wait to try these!!!! Thanks, Excel Lambda!
 

Forum statistics

Threads
1,215,134
Messages
6,123,237
Members
449,093
Latest member
Vincent Khandagale

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