SCAN Function not working in Excel Table

Fowmy

Well-known Member
Joined
Jul 10, 2008
Messages
516
Office Version
  1. 365
Platform
  1. Windows
Hi

How to make the SCAN function work in an Excel table? I am trying to get the running total but not getting the expected results. This works with ranges.

Thanks
Fowmy
 

Attachments

  • RZYaaupe6M.png
    RZYaaupe6M.png
    39.4 KB · Views: 16
I figured it out, ..
Whilst you have used a 'new' function to achieve the running total you wanted, it is not quite the same thing that you were attempting with the SCAN function. If SCAN was successful then it it would have spilled all the results down the table from the top cell, just as it does for a range as you mentioned in post 1. REDUCE does not do that, even for a range - see below.

Here is a 'range' example to demonstrate. Each formula is entered in a single cell. Only SCAN produces a result for each row of the input range. The O16 formula also uses the whole range as input but only produces the final sum of the column. The P16 formula is the equivalent of what you have shown in post 9 and only produces a result for that single cell that it is entered in (unless copied down each row). It 'works' in your table for the same reason that an 'ordinary' formula does, the formula is automatically copied down the table column calculating a single result on each line, not a spilled result from the top cell.

Fowmy.xlsm
MNOP
1622172
1735
18611
19516
20117
Sheet1
Cell Formulas
RangeFormula
N16:N20N16=SCAN(0,M16:M20,LAMBDA(a,b,a+b))
O16O16=REDUCE(0,M16:M20,LAMBDA(a,b,a+b))
P16P16=REDUCE(0,M$16:M16,LAMBDA(a,b,a+b))
Dynamic array formulas.


Why use reduce, rather than just sum, I think it would be far less efficient.
Agreed. I just did a test. In col S below, 1000 rows with random numbers 1-99.
Col S with equivalent of post 6 formula: 0.013 seconds to recalculate the 1000 results
Col T with equivalent of post 9 formula: 0.345 seconds to recalculate the 1000 results. ie About 26 times slower.

Fowmy.xlsm
STU
1636363
259122122
337159159
442201201
563264264
677341341
714355355
866421421
951472472
1061533533
116539539
1227566566
Sheet1
Cell Formulas
RangeFormula
T1:T12T1=SUM(INDEX(S:S,1):S1)
U1:U12U1=REDUCE(0,INDEX(S:S,1):S1,LAMBDA(a,b,a+b))
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,216,069
Messages
6,128,599
Members
449,460
Latest member
jgharbawi

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