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
860
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
Details .xlsx
ABCDEFGHIJKLMNOPQRSTUV
1Calling DET with dif. argumentsmain example =DET(To[Order],Tb[Order ID],Tb[[Product Name]:[Qty]],Tb[[#Headers],[Product Name]:[Qty]],To[Details])
23 clms details =DET(To[Order],Tb[Order ID],Tb[[Product Name]:[Price]],Tb[[#Headers],[Product Name]:[Price]],To[Details])
3clms not next to ech oth. =DET(To[Order],Tb[Order ID],HSTACK(Tb[Customer ID],Tb[Category]),{"ID","Cat"},To[Details])
4Show Invoice Details3 clm details
5=DET(To[Order],Tb[Order ID],Tb[[Product Name]:[Price]],Tb[[#Headers],[Product Name]:[Price]],To[Details])
6OrderCompany NameDatePaidShippingItemsDetails↓↓↓↓↓
7202025Ocean's Edge Surf14-07-24YesGround1 
8202126Oceanfront Surf10-07-24YesGround3Product NameQtyPrice
9202037Ocean Trail20-07-24YesGround2AquaLume LED Light Kit418.99
10202106Pacific Waves16-07-24YesNext Day5TideProof Paddle Jacket564.99Product NameQtyPrice
11202140Breaker Point Surf20-07-24NoNext Day1ShoreLine Collapsible Paddle159.99TideLock Deck Bag179.99
12202121Ocean Explorer13-07-24YesGround5Product NameQtyPriceReef Master Eco Board1189
13201921Coastline Surf19-07-24YesGround1Wave Rider Surf Series1449Wave Rider Surf Series1449
14201950Maritime Surf18-07-24YesAir2ReefFlex Anti-Slip Deck Pad164.99ShoreLine Collapsible Paddle259.99
15201934Ocean Mist Surf18-07-24NoGround1Logo Tshirt121.99Logo Tshirt121.99
16202011Surf Gateway19-07-24YesAir5SunBask Leisure Paddle1279Product NameQtyPrice
17201990Oceanfront Surf09-07-24NoGround5Logo Tshirt121.99HydroThrive Safety Leash118.99
18202167Surf Expedition19-07-24NoGround4Product NameQtyPriceOcean Sprint Racing Pro31499
19202081Wave Serenity17-07-24NoGround5Logo Tshirt521.99ShoreLine Collapsible Paddle359.99Product NameQtyPrice
20202148Ocean's Edge Surf13-07-24YesGround4Logo Tshirt421.99Logo Tshirt221.99SunShield Rash Guard429.99
21202051Surf Sanctuary18-07-24NoGround1SunShield Rash Guard129.99SunShield Rash Guard129.99Carve Performance Board1799Product NameQtyPrice
22201912Swell Surf Co.08-07-24NoAir1SunShield Rash Guard129.99AquaGrip Paddle Gloves229.99Logo Tshirt221.99
23202008Surf Sanctuary10-07-24NoGround4Product NameQtyPriceHydroThrive Safety Leash118.99
24202049Beach Breeze Surf11-07-24NoGround1ReefFlex Anti-Slip Deck Pad164.99Product NameQtyPriceCarve Performance Board3799
25202003Beach Patrol Surf12-07-24YesGround1Wave Rider Surf Series1449HydroThrive Safety Leash218.99Product NameQtyPrice
26202095Surfside Shack14-07-24NoGround1Carve Performance Board1799AquaLume LED Light Kit118.99
27201972Breaker Point Surf09-07-24NoGround1Blue Horizon Explorer11299Product NameQtyPrice
28202169Wave Reef09-07-24NoGround5Product NameQtyPriceHydroThrive Safety Leash118.99
29202130Maritime Surf15-07-24NoNext Day1HydroThrive Safety Leash318.99Product NameQtyPrice
30202085Surf Escape11-07-24YesGround2TideProof Paddle Jacket164.99HydroThrive Safety Leash118.99
31201986Wave Bliss19-07-24NoGround1Wave Rider Surf Series1449
32202059Surf Melody19-07-24NoGround4Wave Rider Surf Series3449Product NameQtyPrice
33202137Ocean Explorer13-07-24NoAir1Carve Performance Board1799Carve Performance Board1799Product NameQtyPrice
34201945Surf Crafters11-07-24NoGround4Reef Master Eco Board2189Wave Rider Surf Series4449
35201982Surf Coast12-07-24YesGround1Product NameQtyPriceHydroThrive Safety Leash218.99
36202151Sea Rider Surf11-07-24NoGround6ClearVue Underwater Camera Mount229.99SunShield Rash Guard129.99Product NameQtyPrice
37201993Surf Gateway13-07-24YesGround1Product NameQtyPriceReefSafe UV Leggings135.99
38202036Tide Pools Surf13-07-24NoGround1HydroThrive Safety Leash218.99Product NameQtyPriceShoreLine Collapsible Paddle259.99
39202073Ocean Mist Surf13-07-24NoGround6Product NameQtyPriceLogo Tshirt421.99ReefFlex Anti-Slip Deck Pad264.99
40ReefFlex Anti-Slip Deck Pad464.99SunShield Rash Guard129.99
41TideProof Paddle Jacket264.99HydroThrive Safety Leash118.99
42SeaPulse GPS Tracker2129.99AquaGrip Paddle Gloves129.99
43SeaPulse GPS Tracker1129.99
44Logo Tshirt121.99
45Sea Bird Cruiser2249
46
Sheet1
Cell Formulas
RangeFormula
J5J5=FORMULATEXT(J7)
J7:U45J7=DET(To[Order],Tb[Order ID],Tb[[Product Name]:[Price]],Tb[[#Headers],[Product Name]:[Price]],To[Details])
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J7:AA50Expression=OR(J7="Product Name",J7="qty",J7="price",J7="id",J7="cat")textNO
J7:AA50Cell Value<>""textNO
B7:H39Expression=$H7textNO


Details .xlsx
ABCDEFGHIJKLMNOPQRST
1Calling DET with dif. argumentsmain example =DET(To[Order],Tb[Order ID],Tb[[Product Name]:[Qty]],Tb[[#Headers],[Product Name]:[Qty]],To[Details])
23 clms details =DET(To[Order],Tb[Order ID],Tb[[Product Name]:[Price]],Tb[[#Headers],[Product Name]:[Price]],To[Details])
3clms not next to ech oth. =DET(To[Order],Tb[Order ID],HSTACK(Tb[Customer ID],Tb[Category]),{"ID","Cat"},To[Details])
4Show Invoice Detailsclms not next to ech oth. (not adjacent)
5=DET(To[Order],Tb[Order ID],HSTACK(Tb[Customer ID],Tb[Category]),{"ID","Cat"},To[Details])
6OrderCompany NameDatePaidShippingItemsDetails↓↓↓↓↓
7202025Ocean's Edge Surf14-07-24YesGround1 
8202126Oceanfront Surf10-07-24YesGround3IDCat
9202037Ocean Trail20-07-24YesGround2108529Accessories
10202106Pacific Waves16-07-24YesNext Day5108529Apparel
11202140Breaker Point Surf20-07-24NoNext Day1108529Accessories
12202121Ocean Explorer13-07-24YesGround5IDCat
13201921Coastline Surf19-07-24YesGround1130926BoardsIDCat
14201950Maritime Surf18-07-24YesAir2130926Accessories117258BoardsIDCat
15201934Ocean Mist Surf18-07-24NoGround1130926ApparelIDCat120035Accessories
16202011Surf Gateway19-07-24YesAir5130926Boards115057Apparel120035Apparel
17201990Oceanfront Surf09-07-24NoGround5130926Apparel
18202167Surf Expedition19-07-24NoGround4
19202081Wave Serenity17-07-24NoGround5
20202148Ocean's Edge Surf13-07-24YesGround4IDCat
21202051Surf Sanctuary18-07-24NoGround1124489Apparel
22201912Swell Surf Co.08-07-24NoAir1124489ApparelIDCat
23202008Surf Sanctuary10-07-24NoGround4124489Accessories117897Apparel
24202049Beach Breeze Surf11-07-24NoGround1124489Apparel
25202003Beach Patrol Surf12-07-24YesGround1
26202095Surfside Shack14-07-24NoGround1IDCat
27201972Breaker Point Surf09-07-24NoGround1116424Accessories
28202169Wave Reef09-07-24NoGround5
29202130Maritime Surf15-07-24NoNext Day1
30202085Surf Escape11-07-24YesGround2IDCat
31201986Wave Bliss19-07-24NoGround1104034Accessories
32202059Surf Melody19-07-24NoGround4104034AccessoriesIDCat
33202137Ocean Explorer13-07-24NoAir1121611Boards
34201945Surf Crafters11-07-24NoGround4IDCat121611Boards
35201982Surf Coast12-07-24YesGround1118065Boards121611Accessories
36202151Sea Rider Surf11-07-24NoGround6118065Apparel121611ApparelIDCat
37201993Surf Gateway13-07-24YesGround1118065Accessories107928Apparel
38202036Tide Pools Surf13-07-24NoGround1118065Accessories107928Accessories
39202073Ocean Mist Surf13-07-24NoGround6IDCat107928Accessories
40123406Accessories107928Apparel
41123406Apparel107928Accessories
42123406Accessories107928Accessories
43123406Accessories
44123406Apparel
45123406Boards
46
Sheet1
Cell Formulas
RangeFormula
J5J5=FORMULATEXT(J7)
J7:O45J7=DET(To[Order],Tb[Order ID],HSTACK(Tb[Customer ID],Tb[Category]),{"ID","Cat"},To[Details])
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J7:AA50Expression=OR(J7="Product Name",J7="qty",J7="price",J7="id",J7="cat")textNO
J7:AA50Cell Value<>""textNO
B7:H39Expression=$H7textNO


Details3.png
 
And this is how it looks with all the checkboxes selected, (too clustered but works acurate). It's like playing Tetris with arrays to the left side 😉
Next will be about the tri state (not only bi) functionality of checkboxes or as I call it Yes, No, Maybe
Details .xlsx
ABCDEFGHIJKLMNOPQRSTUV
1Calling DET with dif. argumentsmain example =DET(To[Order],Tb[Order ID],Tb[[Product Name]:[Qty]],Tb[[#Headers],[Product Name]:[Qty]],To[Details])
23 clms details =DET(To[Order],Tb[Order ID],Tb[[Product Name]:[Price]],Tb[[#Headers],[Product Name]:[Price]],To[Details])
3clms not next to ech oth. =DET(To[Order],Tb[Order ID],HSTACK(Tb[Customer ID],Tb[Category]),{"ID","Cat"},To[Details])
4Show Invoice Detailsclms not next to ech oth. (not adjacent)
5=DET(To[Order],Tb[Order ID],HSTACK(Tb[Customer ID],Tb[Category]),{"ID","Cat"},To[Details])
6OrderCompany NameDatePaidShippingItemsDetails↓↓↓↓↓
7202025Ocean's Edge Surf14-07-24YesGround1IDCat
8202126Oceanfront Surf10-07-24YesGround3113697BoardsIDCat
9202037Ocean Trail20-07-24YesGround2IDCat108529Accessories
10202106Pacific Waves16-07-24YesNext Day5118762Accessories108529ApparelIDCat
11202140Breaker Point Surf20-07-24NoNext Day1118762Apparel108529Accessories106698AccessoriesIDCat
12202121Ocean Explorer13-07-24YesGround5IDCat106698Boards108374Apparel
13201921Coastline Surf19-07-24YesGround1130926BoardsIDCat106698Boards
14201950Maritime Surf18-07-24YesAir2130926Accessories117258Boards106698AccessoriesIDCat
15201934Ocean Mist Surf18-07-24NoGround1130926ApparelIDCat106698Apparel120035Accessories
16202011Surf Gateway19-07-24YesAir5130926Boards115057ApparelIDCat120035Apparel
17201990Oceanfront Surf09-07-24NoGround5130926ApparelIDCat118499Accessories
18202167Surf Expedition19-07-24NoGround4IDCat103467Boards118499Boards
19202081Wave Serenity17-07-24NoGround5108046Apparel103467Accessories118499AccessoriesIDCat
20202148Ocean's Edge Surf13-07-24YesGround4108046Apparel103467Apparel118499Apparel103843ApparelIDCat
21202051Surf Sanctuary18-07-24NoGround1108046Apparel103467Apparel118499Apparel103843Boards124489ApparelIDCat
22201912Swell Surf Co.08-07-24NoAir1108046Apparel103467BoardsIDCat103843Accessories124489Apparel102309Apparel
23202008Surf Sanctuary10-07-24NoGround4IDCat117897Apparel103843Accessories124489Accessories
24202049Beach Breeze Surf11-07-24NoGround1124781AccessoriesIDCat103843Boards124489Apparel
25202003Beach Patrol Surf12-07-24YesGround1124781Boards131827AccessoriesIDCat
26202095Surfside Shack14-07-24NoGround1124781BoardsIDCat131370Accessories
27201972Breaker Point Surf09-07-24NoGround1124781Boards116424AccessoriesIDCat
28202169Wave Reef09-07-24NoGround5IDCat106326Accessories
29202130Maritime Surf15-07-24NoNext Day1127808AccessoriesIDCat
30202085Surf Escape11-07-24YesGround2127808Apparel128291AccessoriesIDCat
31201986Wave Bliss19-07-24NoGround1127808BoardsIDCat104034Accessories
32202059Surf Melody19-07-24NoGround4127808Boards114740Accessories104034AccessoriesIDCat
33202137Ocean Explorer13-07-24NoAir1127808BoardsIDCat121611Boards
34201945Surf Crafters11-07-24NoGround4IDCat104703Boards121611Boards
35201982Surf Coast12-07-24YesGround1118065BoardsIDCat121611Accessories
36202151Sea Rider Surf11-07-24NoGround6118065Apparel104234AccessoriesIDCat121611Apparel
37201993Surf Gateway13-07-24YesGround1118065AccessoriesIDCat107928Apparel
38202036Tide Pools Surf13-07-24NoGround1118065Accessories130011Accessories107928AccessoriesIDCat
39202073Ocean Mist Surf13-07-24NoGround6IDCat107928Accessories108874Apparel
40123406Accessories107928Apparel
41123406Apparel107928Accessories
42123406Accessories107928Accessories
43123406Accessories
44123406Apparel
45123406Boards
46
Sheet1
Cell Formulas
RangeFormula
J5J5=FORMULATEXT(J7)
J7:U45J7=DET(To[Order],Tb[Order ID],HSTACK(Tb[Customer ID],Tb[Category]),{"ID","Cat"},To[Details])
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J7:AA50Expression=OR(J7="Product Name",J7="qty",J7="price",J7="id",J7="cat")textNO
J7:AA50Cell Value<>""textNO
B7:H39Expression=$H7textNO
 
Xlambda, that is mindbogglingly magic that you just check, and the details stack up vertically, but if there is not enough room: BAM! The formula is polite, it stacks it off to the right. : ) : ) : ) : ) : )
 
Great challenge. Great PQ solution:
Extract all item codes that are repeated at least in 3 out of 4 lists (columns) presented in the question table.
And the formula alternative:
Excel Formula:
=LET(a,B4:E17,UNIQUE(SORT(TOCOL(IFS(MAP(a,LAMBDA(x,SUM(--BYCOL(x=a, OR))>2)),a),2))))
Book1
ABCDEFGHIJKLMNOPQ
1Concept for 1 cell (B4)Concept for all cells with MAP
2
3=B5=B4:E17=MAP(B4:E17,LAMBDA(x,SUM(--BYCOL(x=B4:E17,OR))>2))
4X-005X-004X-020X-015FALSEFALSEFALSEFALSEFALSEFALSEFALSETRUE
5X-017X-002X-025X-011TRUEFALSEFALSEFALSETRUEFALSEFALSEFALSE
6X-011X-003X-012X-002FALSEFALSEFALSEFALSEFALSEFALSETRUEFALSE
7X-023X-017X-025X-022FALSETRUEFALSEFALSETRUETRUEFALSEFALSE
8X-015X-012X-012X-017FALSEFALSEFALSETRUETRUETRUETRUETRUE
9X-004X-023X-012X-006FALSEFALSEFALSEFALSEFALSETRUETRUEFALSE
10X-015X-019X-010X-022FALSEFALSEFALSEFALSETRUEFALSEFALSEFALSE
11X-008X-008X-019X-018FALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSE
12X-012X-016X-016X-003FALSEFALSEFALSEFALSETRUEFALSEFALSEFALSE
13X-021X-020X-025X-013FALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSE
14X-012X-009X-014X-023FALSEFALSEFALSEFALSETRUEFALSEFALSETRUE
15X-014X-004X-025X-003FALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSE
16X-013X-016X-024X-021FALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSE
17X-004X-001X-015X-012FALSEFALSEFALSEFALSEFALSEFALSETRUETRUE
18
19=--BYCOL(G4#,OR)Extract all TRUEs
201101=UNIQUE(SORT(TOCOL(IFS(L4#,B4:E17),2)))
21X-012
22=SUM(G20#)>2X-015
23TRUEX-017
24X-023
25Single cell formula
26=LET(a,B4:E17,UNIQUE(SORT(TOCOL(IFS(MAP(a,LAMBDA(x,SUM(--BYCOL(x=a,OR))>2)),a),2))))
27X-012
28X-015
29X-017
30X-023
31
Sheet1
Cell Formulas
RangeFormula
G3,B26,G22,L20,G19,L3G3=FORMULATEXT(G4)
G4:J17G4=B5=B4:E17
L4:O17L4=MAP(B4:E17,LAMBDA(x,SUM(--BYCOL(x=B4:E17,OR))>2))
G20:J20G20=--BYCOL(G4#,OR)
L21:L24L21=UNIQUE(SORT(TOCOL(IFS(L4#,B4:E17),2)))
G23G23=SUM(G20#)>2
B27:B30B27=LET(a,B4:E17,UNIQUE(SORT(TOCOL(IFS(MAP(a,LAMBDA(x,SUM(--BYCOL(x=a,OR))>2)),a),2))))
Dynamic array formulas.
 

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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