9.19 MAP, REDUCE, SCAN, BYROW, BYCOL and MAKEARRAY with Real Examples
Choose what part of the input a LAMBDA should receive
Amir is preparing a fictional grocery report inspired by familiar order screens from Blinkit and Amazon Now. He wants a per-order rule, a running total, and a separate table of quantities and unit prices. Each calculation follows a repeated pattern. Excel's LAMBDA helpers can call a short function repeatedly. The helper determines what arguments are passed on each call and which results appear on the worksheet.
The little function supplied to a helper is sometimes called a callback. It is a calculation that the outer function calls for you. In a MAP over an amount column, each call receives one amount. In a SCAN over the same column, the callback receives the total so far plus one new amount. Its accumulator is the result carried to the next step. You can read those parameter positions as a short description of the information already available.
Match the callback to the operation
| Helper | What each call receives | How the worksheet shows the results |
|---|---|---|
| MAP | One corresponding value per supplied array | One result per input position for the same-sized inputs used here |
| REDUCE | Previous accumulator and the current value | The final accumulator |
| SCAN | Previous accumulator and the current value | Each intermediate accumulator |
| BYROW | One entire source row | One scalar result per source row |
| BYCOL | One entire source column | One scalar result per source column |
| MAKEARRAY | Requested output row and column indexes | One result per generated position |
A scalar is one value, such as a number, label or true/false result. A row sum is scalar even though it reads several cells. Returning an entire row as the result of a BYROW callback does not meet that one-result-per-row contract. Use a separate array construction for a multi-column output.
Microsoft's articles list Excel 2024 for MAP, SCAN, BYROW and BYCOL. REDUCE and MAKEARRAY are listed for Microsoft 365 and the web in their current references, and their documentation does not list Excel 2024. Check every function in the specific receiving app and update channel. You can use an ordinary SUM or running copied SUM as a control for some numeric examples. A simple control is valuable even when the helper is available.
Keep the fictional orders in a known sequence
Enter the ten records below in A1:I11 on Orders. Amount in G, Minutes in H and Qty in F should be numeric. The record states in column I let you compare an amount report with a Delivered order count. The figures and examples are invented, and the practice names FreshGo and MarketRush identify the two scenarios.
| Order ID | Date | City | Platform | Category | Qty | Amount | Minutes | Status |
|---|---|---|---|---|---|---|---|---|
| BLK-1001 | 2 Nov 2026 | Pune | FreshGo | Dairy | 2 | 64 | 9 | Delivered |
| BLK-1002 | 2 Nov 2026 | Nashik | FreshGo | Fruits | 3 | 270 | 12 | Delivered |
| AMN-1003 | 3 Nov 2026 | Pune | MarketRush | Snacks | 1 | 110 | 14 | Delivered |
| BLK-1004 | 3 Nov 2026 | Nagpur | FreshGo | Fruits | 2 | 240 | 11 | Cancelled |
| AMN-1005 | 4 Nov 2026 | Kolhapur | MarketRush | Dairy | 4 | 232 | 16 | Delivered |
| BLK-1006 | 4 Nov 2026 | Pune | FreshGo | Bakery | 5 | 150 | 8 | Delivered |
| BLK-1007 | 5 Nov 2026 | Solapur | FreshGo | Home | 1 | 1299 | 18 | Delivered |
| AMN-1008 | 6 Nov 2026 | Sambhaji Nagar | MarketRush | Staples | 3 | 195 | 10 | Returned |
| BLK-1009 | 7 Nov 2026 | Pune | FreshGo | Snacks | 2 | 220 | 13 | Cancelled |
| BLK-1010 | 8 Nov 2026 | Nashik | FreshGo | Fruits | 1 | 90 | 17 | Delivered |
Lab 1. Compare per-order results, running states and one final result
Use SCAN to see when a running amount crosses a threshold
On Orders put Running amount in J1 and use the following in J2. This reads the ten Amount cells in the original shown order. Keep J2:J11 free. The starting value 0 is the seed, the amount before processing any records.
=SCAN(0,G2:G11,LAMBDA(totalSoFar,nextAmount,totalSoFar+nextAmount))
- The first callback receives zero and 64. It returns 64. The initial zero is not another spill row.
- The second callback sees the previous 64 and the next 270. It returns 334. The third combines 334 and 110 to return 444.
- Continue down the original order sequence. The full result is 64, 334, 444, 684, 916, 1066, 2365, 2560, 2780 and 2870.
- Find the first result greater than ₹1,000, which is 1066 on BLK-1006. The first above ₹2,000 is 2365 on BLK-1007. Neither event refers to the final total alone.
- In K2 enter
=SUM($G$2:G2)and fill down. This conventional running sum should match each result in J. The starting reference stays anchored and the end follows the current row.
Trace the accumulator at four positions
Start with the seed
The running amount is zero before any row contributes.
Process the first amount
The first returned state is 0 plus 64, giving 64.
Carry the result forward
Add 270 to the previous 64. Then add the next 110 to 334, giving 444.
Choose what to return
SCAN shows all ten states, ending at 2,870. REDUCE shows only the final state.
Compare with REDUCE on the same input and state rule
In a free cell try =REDUCE(0,G2:G11,LAMBDA(totalSoFar,nextAmount,totalSoFar+nextAmount)). Expect one numeric result of 2,870. The overall sum is unchanged because this uses the same starting amount and order updates. SUM can deliver this particular final result more simply. The state pattern is useful when each step applies a conditional update.
=REDUCE(0,G2:G11,LAMBDA(totalSoFar,nextAmount,IF(nextAmount>=200,totalSoFar+nextAmount,totalSoFar)))
This version adds only source values at least 200. When the first 64 arrives, the accumulator stays at zero. At the next amount 270, it becomes 270. Only 270, 240, 232, 1299 and 220 qualify, for a result of ₹2,261. A SUMIF with the same condition is an independent check. Use a relevant starting value. Starting from 500 would include that initial number and would change the final plain running sum to 3,370.
Use MAP when each order can be assessed independently
A fictional exercise subtracts 10% from an order amount when its time exceeds 15 minutes. Each callback receives one matching Amount and Minutes pair, and needs no state from earlier rows. Keep both inputs in the same order. Put the following in a free column, then test the rows near its threshold.
=MAP(G2:G11,H2:H11,LAMBDA(orderAmount,minutes,IF(minutes>15,orderAmount*90%,orderAmount)))
BLK-1001 at nine minutes stays ₹64. AMN-1005 at 16 minutes changes from ₹232 to ₹208.80. BLK-1007 at 18 minutes becomes ₹1,169.10, and BLK-1010 at 17 becomes ₹81. The original total 2,870 falls to ₹2,707.90. If you test an exact 15-minute duration on a copy, that order keeps its amount. This fictional adjustment is independent of delivery status. Apply the appropriate status condition if you change the exercise into a Delivered-only scenario.
A direct IF over two aligned arrays can do this particular calculation. MAP is useful when you want to apply a scalar rule to each pair explicitly. For example, an AND in the callback can combine one amount and one quantity test at a time. Try =MAP(G2:G11,F2:F11,LAMBDA(orderAmount,qty,AND(orderAmount>=200,qty>=2))). Four records pass. BLK-1007 has a high amount but qty 1. A single AND evaluated over whole columns would combine them into one Boolean result instead of ten independent decisions.
Lab 2. Summarize the same weekly grid by row and by column
Build this A1:E4 sales practice grid on Weekly. All measures are amounts in thousands of rupees. A row describes one city across four weeks, while a column describes a single week across three cities. Do not include City labels in the numeric input. You saw these values in the TOCOL lesson, but here each original row and column retains its grouping.
| City | W1 | W2 | W3 | W4 |
|---|---|---|---|---|
| Pune | 520 | 610 | 580 | 700 |
| Nashik | 300 | 280 | 350 | 330 |
| Nagpur | 410 | 390 | 450 | 470 |
=BYROW(B2:E4,LAMBDA(weekAmounts,SUM(weekAmounts)))
=BYCOL(B2:E4,LAMBDA(cityAmounts,SUM(cityAmounts)))
- In G2 enter the first expression. The first callback sees Pune's entire four-value row and returns 2,410. Nashik and Nagpur give 1,260 and 1,720. The result has three rows by one column and preserves city order.
- In B6 enter the second expression. The first callback sees all three cities for W1, 520, 300 and 410. It returns 1,230. The remaining week totals are 1,280, 1,380 and 1,500. The result has one row by four columns.
- Compare the sum of each result with
=SUM(B2:E4). Both report the same twelve observations partitioned in different ways and each total gives 5,390. - Use
=BYROW(B2:E4,LAMBDA(weekAmounts,MAX(weekAmounts)))to return the largest amount per city. Expect 700, 350 and 470. Each callback still returns a single value. - In a separate cell use
=BYROW(B2:E4,LAMBDA(weekAmounts,AND(DROP(weekAmounts,,1)>DROP(weekAmounts,,-1)))). This compares W2, W3 and W4 against W1, W2 and W3 for each city. All three cities have at least one drop, so all three results are FALSE.
The growth formula gives one Boolean result for each city. For Pune, compare 610 against 520, 580 against 610, and 700 against 580. The middle comparison is false. AND collapses those three comparisons into one answer, exactly what the BYROW callback needs. It should be replaced with a per-pair result design if the viewer needs to see which specific week declined.
Use explicit positions for a calculation within each record
Return to Orders for one smaller case. The source F2:G11 has two fields, Qty then Amount. Each BYROW callback sees one row with two columns. Use =BYROW(F2:G11,LAMBDA(rowValues,INDEX(rowValues,1,2)/INDEX(rowValues,1,1))) to return amount per item. The index uses row 1 within the single-row input, then chooses column 2 for Amount and column 1 for Qty. The first result is 64 divided by 2, giving 32.
Only divide by positive quantity in the actual calculation. In a scratch copy set the first Qty to zero and inspect the natural division error. For a report that should continue, read the two fields with LET and return Check Qty before dividing when quantity is zero or otherwise invalid. A name should document whether it gives a text status or raises a data error. Test one correct row alongside the intentional failure.
Generate a new price grid from coordinates
On a new PriceGrid sheet, put Milk, Bread and Eggs in B1:D1, then unit prices 32, 45 and 60 in B2:D2. Prices are invented and in the same currency. A workshop buyer wants a five-by-three table. Along each row, buy the corresponding quantity of each single product. Across each column, keep the unit price for that product. The requested output row represents quantity one through five.
=MAKEARRAY(5,3,LAMBDA(rowIndex,columnIndex,rowIndex*INDEX($B$2:$D$2,1,columnIndex)))
In B5 put the formula with a clear result area through D9. The helper calls LAMBDA with row and column positions starting at one. At its second row and third column, rowIndex is 2 and columnIndex is 3. The selected unit price is 60 and the result is 120. At row five column three the result is 300. At row three column two, 3 times 45 gives 135. These count from the output's top left rather than using actual worksheet row numbers.
| Quantity | Milk 32 | Bread 45 | Eggs 60 |
|---|---|---|---|
| 1 | 32 | 45 | 60 |
| 2 | 64 | 90 | 120 |
| 3 | 96 | 135 | 180 |
| 4 | 128 | 180 | 240 |
| 5 | 160 | 225 | 300 |
In a copy change Bread's unit price to 50. Only its column changes, to 50, 100, 150, 200 and 250. The row labels and other prices remain valid. Restore 45 before using the source case again. If the requested width becomes four, the fourth output column would try to select a price not present. Tie the target width to the actual price range when that is the intended control, and check that the labels grow with it.
Choose a starting state that matches the measurement
The first running-sum example starts at zero because nothing has been added. If a prior day ended at ₹500 and the new source only has this day's orders, entering 500 as the opening amount produces 564 on the first row and 3,370 by the end. Label the result as cumulative amount including opening balance. That same value would be wrong for the day's total alone.
Carry forward the largest time seen so far
=SCAN(0,H2:H11,LAMBDA(highestSoFar,nextMinutes,MAX(highestSoFar,nextMinutes)))
The ten states of the running maximum are 9, 12, 14, 14, 16, 16, 18, 18, 18 and 18. At the fourth record the duration was 11, so the previous maximum 14 stays. The calculation measures the worst elapsed time so far, not the total number of minutes. Check three rows where the result changes and an intervening one where it does not.
A seed of zero works for the current nonnegative durations. A practice change list could contain only negative values. Try a scratch range A2:A4 with −5, −2 and −9. A maximum scan starting at 0 would keep 0, which no input supplied. To use the maximum of the observed data so far, use the first actual value as the seed in this MAX example. The state then returns −5, −2 and −2. Processing the first value again cannot change a maximum. The same repeated first-value approach would add the first value twice in a sum, so choose a seed with the specific operation in mind.
When matching a running result to an order date, confirm the source is in the desired sequence and handle ties deliberately. SCAN follows the input order. If you sort just the amounts without their IDs, you change the points at which the cumulative total crosses ₹1,000 and lose which orders generated those points. A chronological report should sort complete records first. Test the first two IDs and the position of a crossing.
Use a sequence of text replacements as the state
REDUCE can carry a text value as well. In a scratch text exercise, suppose a controlled older report writes the numeric amount as Rs. 1,299/-. B2:B4 on TextCheck contains three known tokens to remove: Rs. then a comma, then slash and hyphen. The initial state is the full text. Each pass receives the current text and one token. Express them as separate cells rather than relying on an array literal for this example.
=TRIM(REDUCE("Rs. 1,299/-",B2:B4,LAMBDA(cleaned,nextToken,SUBSTITUTE(cleaned,nextToken,""))))
The first removal leaves a leading space before 1,299/-. The comma removal changes the numeric-looking text to 1299/-. The final token removal leaves the leading space and 1299. TRIM removes the unwanted edge space. The output is text 1299. Convert to a number only if the source policy guarantees the integer format. Do not strip a genuine minus sign or decimal point from data that uses them to represent amounts. Chapter 9.12 shows how to keep decimal separators meaningful.
Compare all helper output shapes on one tiny product fixture
On Tiny, enter Product, Qty, Unit price and Amount in A1:D1. Use three products: Pen, 10, 5; Book, 4, 50; Bag, 2, 200. In D2 multiply Qty by Unit price and fill down through D4. The amounts are 50, 200 and 400. The numerical source rows are separate observations. Their amount total is 650 and their quantity total is 16.
- Three individual charge adjustments.
=MAP(D2:D4,LAMBDA(amount,amount*10%))returns 5, 20 and 40. The result has the shape of the amount column and one numeric value per item. - One final amount.
=REDUCE(0,D2:D4,LAMBDA(totalSoFar,amount,totalSoFar+amount))returns 650. SUM over the same amount column is the direct control. - Three accumulating totals. The same state rule with SCAN outputs 50, 250 and 650. There is no zero output row. The first value equals the first amount in this zero-seeded state.
- One calculated amount per complete row. In
=BYROW(B2:C4,LAMBDA(rowValues,INDEX(rowValues,1,1)*INDEX(rowValues,1,2))), each row's two fields multiply to make the same 50, 200 and 400. - Two separate useful totals. In a scratch range F1:G4 copy Qty and Amount as two separate measures.
=BYCOL(F2:G4,LAMBDA(measure,SUM(measure)))returns 16 units and 650 rupees with a distinct label for each. Summing the two results as a single figure would mix units. - A generated comparison table.
=MAKEARRAY(3,2,LAMBDA(rowIndex,columnIndex,INDEX(D2:D4,rowIndex)*CHOOSE(columnIndex,10%,20%)))produces three product rows and two charge-rate columns. The rows are 5 and 10, 20 and 40, then 40 and 80.
This fixture is small enough to verify every cell. Notice that MAP and BYROW may return the same shape in some examples, but they receive different inputs. MAP in the first formula takes one amount per call. BYROW in its example receives both Qty and Unit price as one row. Use the callback's input contract to choose between them. It helps explain why a two-parameter LAMBDA is needed for two MAP arrays but only a single row parameter belongs to BYROW.
Practice and answer key
Use the original Orders and Weekly fixtures. Choose a free area so your result fits. Identify which input field reaches the callback before reviewing the answer.
Compute amount per item for each of the ten orders
=MAP(G2:G11,F2:F11,LAMBDA(orderAmount,qty,IF(qty>0,orderAmount/qty,"Check Qty"))) returns one value for each pair. The first is 64 divided by 2, or 32. With clean positive quantities the second is 270 divided by 3, or 90. A zero entry in the test copy should produce Check Qty in that row.
Return only the final sum with REDUCE
=REDUCE(0,G2:G11,LAMBDA(totalSoFar,amount,totalSoFar+amount)) returns 2870. The state starts at zero and adds each amount. The formula returns a single value at the end.
Return the running sum using the same state rule
=SCAN(0,G2:G11,LAMBDA(totalSoFar,amount,totalSoFar+amount)) gives ten states. The third is 444 and the final one 2870. Compare the third state with 64 plus 270 plus 110.
Use an entire row to compute amount per item
=BYROW(F2:G11,LAMBDA(rowValues,INDEX(rowValues,1,2)/INDEX(rowValues,1,1))) returns 32 for the first row. Here each callback takes a single 1×2 array. Its two field positions are known. Use only the clean positive-quantity fixture for this version.
Find the two original totals for Qty and Amount
=BYCOL(F2:G11,LAMBDA(valuesInColumn,SUM(valuesInColumn))) gives 24 and 2870, one result per source field. They represent 24 units and ₹2,870 separately. Label them rather than adding the two values together.
Generate a multiplication table from output positions
=MAKEARRAY(3,3,LAMBDA(rowIndex,columnIndex,rowIndex*columnIndex)) produces 1, 2, 3 on its top line, 2, 4, 6 on the second and 3, 6, 9 on the bottom. The bottom-right value 9 follows from both positions being 3.
Track the running number of Delivered orders
=SCAN(0,I2:I11,LAMBDA(countSoFar,nextStatus,countSoFar+(nextStatus="Delivered"))) gives 1, 2, 3, 3, 4, 5, 6, 6, 6 and 7. Adding a true condition increments by one. The fourth record is cancelled, so the count repeats 3 in that row.
Average each city's weeks and check a generated coordinate grid
On Weekly, use =BYROW(B2:E4,LAMBDA(weekAmounts,ROUND(AVERAGE(weekAmounts),1))) for 602.5, 315 and 430. In a clear location, =MAKEARRAY(3,3,LAMBDA(rowIndex,columnIndex,rowIndex*10+columnIndex)) returns rows 11,12,13 then 21,22,23 then 31,32,33. Those outputs independently confirm axis order.
Test the callback's arguments, result and input types
Check the number of arguments for one call
MAP with two same-sized arrays supplies two values to each callback. For the coupon that means Amount first and Minutes second. An incorrectly declared parameter count can produce an Incorrect Parameters error. When a formula's inputs are reversed, even a valid parameter count can give a plausible wrong number. Write the single first-record call on paper before testing the full column. The amount is 64 and the minutes are 9. They represent different quantities.
BYROW supplies one array as one argument. If the callback uses each record's values separately, index those fields from that array. BYCOL similarly supplies one entire column. MAKEARRAY takes dimension numbers and passes a row position and a column position to the rule. It does not take one source row as that first parameter. Compare these contracts using a small positive fixture. Use distinct parameter names so one position cannot be confused with another.
Check the single value that each helper returns
For BYROW on Weekly, test with a simple SUM first. It returns a single amount for every city. A formula that tries to return all four input values each time does not follow its scalar requirement. Microsoft documents a calculation error when a BYROW or BYCOL callback returns something other than a single value. To create another grid, use a different function or combine independent results with appropriate dimensions.
With MAKEARRAY, start with the coordinate code rowIndex times ten plus columnIndex. It should show 11 at the first position and 23 at row two, column three. This proves positions and orientation without depending on catalogue values. Next use those positions to select or compute a real result. Check that every requested index exists in any source field you read.
Apply type checks before arithmetic when an input can be invalid
For a per-order unit cost, a zero quantity prevents division. In the clean fixture, MAP can test one pair at a time. If you deliberately enter zero in Orders F2, a checked division gives Check Qty for the first row while other records keep their values. An explicit data policy can also reject text and missing values before producing a report. Do that validation in the original fields where blanks are visible. Report how many records had unusable inputs instead of silently converting the results.
For the weekly grid, keep the grouping labels even when source errors are present. Do not replace an entire row with zero solely to get a group result. If the report ignores some weeks, list the number of included observations so someone can interpret an average. A row sum of two observed weeks and a row sum of four describe different coverage even if their values match.
Use source ranges that can actually grow
If you can express a check with a standard worksheet function, keep it during development. SUM validates a final amount, COUNTIF checks Deliveries, and a filled running SUM checks the intermediate states. Agreement on the complete clean fixture helps isolate a later mismatch to the callback or to different source membership.
The Orders examples read row 2 through row 11. Writing an additional row does not extend those fixed references. If the worksheet uses an Excel Table, pass its named fields and check the next record is inside the Table. For a paired MAP, keep both fields from the same Table so they have the same records. In a chart ensure the source uses the output's updated spill rather than a fixed old rectangle. Verify an added known amount and the new number of states.
Change the running report's order without losing record identity
The original running total measures the source order. Suppose the workshop manager wants to compare accumulated amount after ranking the largest individual orders first. This is an alternate analysis with a different sequence, not the timeline of actual transactions. Keep the ID and Amount together while sorting. Then give the sorted amount field to SCAN and append its states alongside the sorted records.
=LET(ordered,SORTBY(HSTACK(A2:A11,G2:G11),G2:G11,-1,A2:A11,1),
running,SCAN(0,CHOOSECOLS(ordered,2),LAMBDA(totalSoFar,amount,totalSoFar+amount)),
HSTACK(ordered,running))
- Enter the expression in a free three-column by ten-row area on Orders. The first field is ID, the second is amount and the third carries the running value.
- Check the first row. Sorted by descending amount, BLK-1007 appears first with 1,299. Its accumulated state is already 1,299 and therefore exceeds 1,000. In the original order the crossing happened later at BLK-1006.
- Check the fourth row and the second milestone. The first four ranked amounts are 1,299, 270, 240 and 232, with intermediate totals 1,299, 1,569, 1,809 and 2,041. The fourth order is AMN-1005 and crosses 2,000 in this view.
- Check the final sum. It is still 2,870 since sorting moved complete records without changing the source values. A matching final sum cannot tell you whether the intermediate sequence matches a timeline.
The last HSTACK puts each sorted row beside a state computed from that exact sorted amount sequence. The same set of ten states would pair incorrectly if you placed it beside the original unsorted IDs. If two amounts tie, the additional ID key sets a reproducible order. For production, choose the sort keys with the person who needs the timeline or ranking. An arbitrary row chosen first after a tie may mislead if the report cares about transaction time.
Derive a useful companion measure from the same state sequence
If the manager wants a marker when the report first goes over 2,000, look up the first TRUE in a comparison of the running sequence with the threshold. Preserve the record key in that operation. The original and ranked report should identify their respective seventh and fourth sequence positions for that milestone. In a source with no crossing, return a message rather than pretending the last observation met the threshold. A separate marker could show which report uses time and which uses value order.
For the original J2 running amount test, place the milestone in M2. Then in a spare cell use =XLOOKUP(TRUE,J2#>$M$2,A2:A11,"No crossing"). It tests every running state and returns the first record ID whose comparison is true. The ID range is in the same original order as J2. Check 1000 returns BLK-1006 and 2000 returns BLK-1007. With 2870 the result is No crossing because the last state equals rather than exceeds that value.
If you use the ranked result instead, derive both the state column and ID column from that same three-field spill. Otherwise the copied milestone formula could return an earlier unsorted ID for the new sorted position. Change both ranges together and compare a known run in the new order. This is an example of a general principle: arrays that produce one row per source item also need a shared order and boundary when you use them together.
For this test, verify ranks by ID and amount before verifying the cumulative result. A row grows when it receives a positive amount, while a future scenario with negative adjustments can make the state decrease. If that is a supported measure, decide whether the request is a first crossing, a last crossing or every crossing. A single final total still cannot establish which happened.
Quiz with explained answers
Which helper shows the point where a running amount first exceeds ₹1,000?
SCAN returns the intermediate accumulator for each row. In the practice sequence it first exceeds 1,000 at BLK-1006 with 1,066. REDUCE returns the final 2,870 and does not describe where that threshold was crossed.
Why are there ten results with a SCAN seed of zero and ten input amounts?
The seed is the previous amount before the first callback. Each returned result appears after an input is processed. The first is 0 plus 64, which gives 64. There is no extra row containing only the seed.
What amount and time values does the first coupon callback receive?
64 and 9 from the same order, BLK-1001. A nine-minute duration is within the fictional threshold, so it returns 64. The rule sees one pair from the matching input positions and does not need any previous amount.
How many values does BYCOL return for a three-city, four-week input?
Four, one per week column. It produces a horizontal 1×4 result. The first value is the W1 sum 1,230. BYROW produces three, with a result for each city instead.
What is sent to the price-grid callback at its row 2, column 3?
Output positions 2 and 3. Under the rule, the row position gives quantity 2, while column 3 selects the Eggs price of 60. The result is 120. These indices are relative to the generated grid.
Why is a zero seed unsuitable for the maximum of an all-negative list?
A maximum with seed zero can remain zero even though no source value reached it. For the example −5, −2, −9, using the initial observation for a MAX comparison gives observed running maxima −5, −2 and −2. Choose the starting condition to match the measurement.
Interview questions you can answer from practice
When would you choose MAP instead of a direct worksheet IF?
For simple element-wise arithmetic, either may be clear. MAP helps when a named scalar rule must receive one value or one paired record at a time. For example I can use AND with one quantity and one amount in a MAP callback. An AND over both whole ranges would give a single combined result.
How can you prove BYROW and BYCOL report the same population in different groups?
Calculate each group from the same numeric body. Verify one city sum and one week sum independently. Add the city results separately and the week results separately. Both give 5,390 on the twelve-value fixture. Keep the labels so the direction of the grouping is clear.
How would you use REDUCE to change text step by step?
Set the starting state to the original text and provide the list of exact replacement tokens as the second input. Each callback uses the current text and the next token to produce the new text. The final state is the cleaned string. Check the source notation before removing separators or signs.
How would you troubleshoot a helper reporting an incorrect number of parameters?
Read what the helper passes each time. MAP with two arrays calls with two values. BYROW calls with one whole row. SCAN calls with a previous state and a new item. Rewrite the small callback test with the intended number and order of arguments before using the full range.
When would you choose MAKEARRAY for a new worksheet output?
Use it when the result can be computed from its generated row and column positions. A grid of quantity and product-price scenarios is a good example. Define the dimensions and prove a corner and one interior cell. Make sure references used by the rule cover all the requested positions.
Revision cards
- MAP handles corresponding values. Keep its inputs aligned position by position.
- REDUCE returns the final state. Set a deliberate starting value.
- SCAN keeps every state. Match the sequence to the business order.
- BYROW returns one result per row. Give it a callback that produces one value.
- BYCOL returns one result per column. Preserve units and headings when displaying the output.
- MAKEARRAY generates positions. The callback reads output coordinates starting at one.