Ravindra BagaleCourses & study guides मराठी Track your progress

9. Dynamic Arrays

Excel

9.6 LET

Give each part of a formula a name you can explain

A fictional grocery coordinator wants the average amount per order for a selected city. The worksheet needs the total amount for that city, the number of its orders and a rule for the case where there are none. Those parts can be hidden inside one long expression. If the city rule later changes, it is easy to repair the sum and forget to repair the count. LET lets you assign readable names to intermediate values inside the formula, then state how the names produce the result.

A local name in LET is a label that exists inside that formula. It can refer to a number, a cell’s value, an entire array or the result of another operation. For example, cityChoice can name the selection in a worksheet cell, and orderCount can name the number of records that match. Another formula written elsewhere cannot use those names directly. That formula would need its own names, a normal cell reference or an intentionally defined workbook name.

The values below are invented practice data based on familiar order contexts from Blinkit, Amazon Now and Swiggy. The amounts and timing rules do not describe the commercially used policies of any of those brands.

Read the names, their definitions and the final expression

LET alternates a name and the value to assign to that name. After those pairs, the last argument is the calculation or expression to return. A later definition can read an earlier name from the same formula. Use the local expression in the order it is defined. In the simple example below, baseAmount is 100 and practiceRate is 10%. The last arithmetic expression calculates a hypothetical fee.

=LET(baseAmount,100,practiceRate,10%,baseAmount*practiceRate)

The answer is 10. Putting that formula in one worksheet cell does not create names in other cells. To see a different result, use a separate expression with its own rate. If a value should be shared, put it in a labelled Settings cell and reference that cell in each formula. This distinction matters when readers assume a local name created in one report is also available in another tab.

Check the sequence of each name and its value.
PartExampleRole
NamebaseAmountReadable local label
Value100Value assigned to the first label
Second definitionpracticeRate with value 10%Second named input
ResultbaseAmount × practiceRateExpression returned to the worksheet

Choose names that are valid in Excel and meaningful in the problem

  • Start with a letter. Choose a readable identifier such as reportCity, cityAmount or eligibleRows.
  • Give the name one clear meaning. Keep the amount, count and Boolean mask distinct. A name such as result could describe any of them.
  • Avoid address-like names. A1 resembles a worksheet reference. Microsoft also gives single-letter c as an invalid LET name because of the R1C1 reference style. Use cityChoice instead.
  • Define each name before using it later. In an average, identify the matching population once, then use the same criteria for the sum and the count.
  • Finish with the result expression. Ask what the formula should return to the grid after the last name/value pair. A series of definitions is not a complete output by itself.

Microsoft describes LET as a way to keep repeated expressions readable and calculate a named expression once when it is reused. For example, if a filtered array supplies both a count and an extracted amount, naming that array makes it explicit that both use the same result. That does not guarantee a particular workbook speedup. Measure any performance problem on the actual workload instead of guessing from formula length. In a beginner workbook the main benefit is a formula another person can check.

Lab 1. Use one city setting for both amount and order count

Build a practice Table named tblLet using the following data in A1:D11 on Orders. This four-field layout spells the relevant fields exactly as they appear in the formulas. Use numbers for Amount. The calculation answers “average amount of all recorded orders in the selected city.” It deliberately includes a cancelled order if it belongs to that city because this first question does not filter Status.

Orders A1:D11. Use these exact headings and numeric amount values.
Order IDCityAmountStatus
BLK-1001Pune64Delivered
BLK-1002Nashik270Delivered
AMN-1003Pune110Delivered
BLK-1004Nagpur240Cancelled
AMN-1005Kolhapur232Delivered
BLK-1006Pune150Delivered
BLK-1007Solapur1299Delivered
AMN-1008Sambhaji Nagar195Returned
BLK-1009Pune220Cancelled
BLK-1010Nashik90Delivered

Enter the definitions and then the final branch

On a separate Check tab, put City choice in L1 and Pune in M1. Put Average order amount in L2. In M2 enter:

=LET(cityChoice,$M$1,
     cityAmount,SUMIFS(tblLet[Amount],tblLet[City],cityChoice),
     orderCount,COUNTIFS(tblLet[City],cityChoice),
     IF(orderCount=0,"No orders",cityAmount/orderCount))
  1. Check cityChoice. The first local name reads M1, so Pune supplies the criterion. That same name is available for both subsequent definitions.
  2. Check cityAmount and orderCount separately. BLK-1001, AMN-1003, BLK-1006 and BLK-1009 match. Their amounts 64, 110, 150 and 220 add to 544. There are four records.
  3. Read the final IF. A zero count returns No orders. A nonzero count can be used as the denominator. Dividing 544 by 4 gives ₹136. The worksheet output is one value.
  4. Change only the city setting. Nashik gives two amounts, 270 and 90, so the average is ₹180. Solapur has one order worth ₹1,299. Delhi gives zero matching rows and the message. Try all three states before returning to Pune.
With Pune selected, cityAmount is 544 rupees and orderCount is 4. The formula computes an average of 136 rupees.
Read the named amount and count before deciding what the formula should display.

Test zero amounts and missing observations separately

Use a scratch copy to set the four Pune amounts to numeric zero. A count of four still proves orders exist, so the formula should return 0. An earlier style of test checking whether the city’s sum equals zero would incorrectly display No orders. A zero amount can be valid, for example in a deliberately free practice order. Restore the original four values after the test.

Next clear only the ₹64 amount from BLK-1001 on the scratch copy. The City label is still present. The amount sum becomes ₹480 and the count of matching order records stays four. Dividing 480 by four returns ₹120. That treats this sum as an amount per recorded order regardless of completeness. If the request instead means the average of the three valid numeric amounts, the denominator should be three and the answer is ₹160. These answers differ because one amount is unknown. A formula or presentation label should not silently report an incomplete list as if the missing amount were known to be zero.

For the valid-amount policy on the clean numeric-or-blank fixture, compute a separate measuredCount using SUMPRODUCT(--(tblLet[City]=cityChoice),--ISNUMBER(tblLet[Amount])) inside the same LET formula. Use that as the denominator when it is positive, and return a no-observation message when it is zero. Keep the order count visible to show completeness. If there are formula errors rather than blanks, inspect them and apply an explicit documented handling policy. Do not assume this small blank check handles every kind of invalid source.

Lab 2. Read a multi-row expression one named stage at a time

A fictional Swiggy-inspired workshop asks for delivered orders from a selected city whose timing is strictly above a chosen number of minutes. The final report should show the highest amount first. Use a separate practice sheet, ReportLab, to enter the six rows below. The cutoff and amounts are arbitrary practice values.

ReportLab A1:E7. Amount and Mins are numeric fields.
Order IDCityStatusAmountMins
SW-31PuneDelivered24016
SW-32NashikDelivered1808
SW-33PuneCancelled30019
SW-34PuneDelivered15020
SW-35PuneDelivered36020
SW-36NashikDelivered26015

Define the source, mask and count before building the final result

Put City in G2 and Pune in H2. Put Minutes above in G3 and 12 in H3. Place the five result headings in J5:N5, leaving room below them through the largest report you will test. Enter the following formula at J6.

=LET(reportCity,$H$2,
     minuteCutoff,$H$3,
     sourceRows,A2:E7,
     keepRows,(B2:B7=reportCity)*(C2:C7="Delivered")*(E2:E7>minuteCutoff),
     matchCount,SUM(keepRows),
     IF(matchCount=0,"No matching deliveries",SORT(FILTER(sourceRows,keepRows),4,-1)))
  • reportCity and minuteCutoff. These two names supply the selected city and numeric boundary. You can read these inputs at the top of the formula.
  • sourceRows. This name covers the six data records and five returned fields. It leaves out the headings.
  • keepRows. This name represents one inclusion value per record. The original Pune and 12 settings give 1, 0, 0, 1, 1 and 0. For SW-33 the city and minutes qualify and the status fails.
  • matchCount. Sum the 1s. The result is 3. This branch manages the no-match case before sorting the returned data by the fourth field.
  • Final expression. With matches, return the five-field data and sort Amount descending. The original order of matching rows is SW-31, SW-34, SW-35. The sorted report gives SW-35, SW-31, SW-34. Their total is ₹750.
The inclusion values are 1, 0, 0, 1, 1 and 0. The match count is three. The sorted IDs end with 35, 31 and 34 in that order.
Inspect a stage’s output first, then explain how the next stage uses it.

Inspect a local name without changing your working report

Copy the formula to an independent scratch area, making sure the returned range and input references remain the ones from the original report. For example, copying a formula can shift unanchored ranges. Type the exact displayed expression into a free location on ReportLab or use explicit ReportLab references if testing on a separate sheet. In one test replace only the final IF expression with keepRows. It now outputs the six inclusion values directly. In a second test request matchCount as the final expression and verify the single result 3. Return to the original full expression in the real exercise cell. This is a way to see a value you cannot reference as a local name from a different worksheet formula.

Raise the minute cutoff to 16. SW-31 is now exactly at the cutoff and leaves the result, so SW-35 and SW-34 remain and total ₹510. Choose Nashik and return the cutoff to 12. Only SW-36 remains at ₹260. Choose Delhi and expect the message with no returned records. Verify one failing and one passing record in each state. Your test should make clear whether a change affected the mask, count or final sorted output.

Open the expression one stage at a time

  1. Read the inputs

    City is Pune and minutes must be strictly greater than 12. The report requires Delivered status.

  2. Inspect keepRows

    Read 1, 0, 0, 1, 1, 0 in source order. The 19-minute cancelled order is excluded.

  3. Count before returning data

    There are three matches. A zero count would return a message without asking the sort to read a data column that is absent.

  4. Read the final order

    Read SW-35 at ₹360, SW-31 at ₹240 and SW-34 at ₹150. They are selected first, then sorted by Amount.

Reuse the same selected records for more than one check

Use the first Pune run of ReportLab. The delivered and over-12-minute rule is already present in keepRows. Suppose a supervisor needs two checks from those exact matches: average amount and average minutes. Both should describe the same three orders. Writing a separate FILTER for every statistic can make it harder to see that the dates, city or cutoff changed between copies. In a client supporting HSTACK, you can build a one-row pair of statistics after naming the filtered records once.

=LET(cityChoice,$H$2,
     minuteCutoff,$H$3,
     keepRows,(B2:B7=cityChoice)*(C2:C7="Delivered")*(E2:E7>minuteCutoff),
     matchedCount,SUM(keepRows),
     IF(matchedCount=0,"No matching deliveries",
        LET(matchedRows,FILTER(A2:E7,keepRows),
            amountValues,INDEX(matchedRows,0,4),
            minuteValues,INDEX(matchedRows,0,5),
            HSTACK(AVERAGE(amountValues),AVERAGE(minuteValues)))))

Read the purpose of each nested calculation

The outer LET reads the user inputs and gives the matching count a name. When that count is zero, it returns an explanatory message. With matches, the inner LET gives the chosen rows and two extracted columns their own names. Those names exist inside that inner formula. INDEX with a zero row argument extracts the entire selected column. The two averages then combine horizontally. Put the headings Average amount and Average minutes above the two-cell result so the user can tell which unit each result uses.

  • Pune and cutoff 12. The three amounts 240, 150 and 360 give an average of ₹250. The three times 16, 20 and 20 total 56 and average about 18.67 minutes. The averages measure different units over the same population.
  • Pune and cutoff 16. The two 20-minute entries remain. Average amount becomes ₹255 and average time is 20 minutes. If one average moved while the other still counted three entries, inspect which criterion each one uses.
  • Delhi. The count is zero. The output shows the message rather than two averages. Keep an independent count for a report that consumes the pair and cannot accept a fallback string as a numeric summary.

On a client with LET and FILTER but no HSTACK, keep independent result cells for the two averages and document the shared rule. For a small spreadsheet, linked helper cells are another good option. They let a novice inspect the mask, matching count and totals without reading a deeply nested expression. A local name is useful when the same value is used inside one formula. A visible worksheet value can be more useful when several different formulas or people need to review it separately.

Try the chapter’s six short calculation tasks

Use the original ten-order Table from Lab 1 and its exact headings. Restore any zero or blank test before starting. These tasks use structured references, so they do not assume the Amount or Status fields occupy the same letters in every practice workbook. Open the result after attempting each calculation. Check what the denominator measures before formatting a number as a percentage or an average.

Calculate total recorded Amount for Delivered orders

Use =LET(isDelivered,tblLet[Status]="Delivered",SUM(FILTER(tblLet[Amount],isDelivered,0))). The status expression produces one test per record. Seven orders qualify and add to ₹2,215. The fallback zero is suitable for this total. It must not add one matching order to a separate record count.

Calculate the Delivered share of total recorded amount

Try =LET(allAmount,SUM(tblLet[Amount]),deliveredAmount,SUMIFS(tblLet[Amount],tblLet[Status],"Delivered"),IF(allAmount=0,"No amount basis",deliveredAmount/allAmount)). The numerator is ₹2,215 and denominator is ₹2,870. The result is about 77.18%. This is a share of value, not the share of orders. Seven out of ten orders would be 70%.

Find the matching average for Pune with a named condition

Use =LET(inCity,tblLet[City]="Pune",AVERAGE(FILTER(tblLet[Amount],inCity))) on this known test population. Expect ₹136. If adapting it to a setting with no matches, check the count before calculating an average, as Lab 1 does. A numeric zero fallback would invent an amount observation.

Apply a hypothetical 18% surcharge to the largest order

Write =LET(maxOrder,MAX(tblLet[Amount]),maxOrder*1.18). The largest amount is ₹1,299, and multiplying by 1.18 gives ₹1,532.82. This is a fictional arithmetic surcharge. A total including a percentage increment differs from the increment alone, which would be ₹233.82.

Count the amounts strictly greater than ₹200

Use =LET(amountValues,tblLet[Amount],SUM(--(amountValues>200))). The comparison supplies TRUE or FALSE per row, then the double minus turns those into numbers. Five rows qualify. Check a known included amount ₹220 and a known excluded amount ₹195.

Find the share of value from Cancelled orders

In a similar ratio use =LET(cancelledAmount,SUMIFS(tblLet[Amount],tblLet[Status],"Cancelled"),allAmount,SUM(tblLet[Amount]),IF(allAmount=0,"No amount basis",cancelledAmount/allAmount)). The two cancelled amounts 240 and 220 total ₹460. Dividing by ₹2,870 gives about 16.03%. Returned is a separate status and contributes ₹195 to the source amount.

Review a reporting change before sharing it

In the fictional Blinkit workbook, the manager now wants the average for delivered orders in whichever city is selected. The original figure of ₹136 answered the question for every Pune row. The new audience could make a poor decision if the number changes and the label stays the same. Put Average delivered order amount beside the new formula. Then identify the rows used for both parts of the calculation.

  1. Restore the original amounts and set M1 to Pune. Use a fresh output cell M5 so the previous result stays available as a control.
  2. Look at Pune records first. BLK-1001, AMN-1003 and BLK-1006 are Delivered. Their amounts are 64, 110 and 150. BLK-1009 is Cancelled with an amount of 220. Write these separate groups beside the report while checking it.
  3. Add only the Delivered Pune amounts. That gives ₹324. Count the same three Delivered entries. On a calculator, dividing 324 by 3 gives ₹108.
  4. In M5 paste the formula below. The two functions each receive both the city and the status criteria. The amount function has an additional first argument because it needs a column to add.
  5. Change M1 to Delhi. Both amount and count become zero. Verify the display says No orders. Change M1 back to Pune and verify ₹108 again.
=LET(cityChoice,$M$1,statusChoice,"Delivered",deliveredAmount,SUMIFS(tblLet[Amount],tblLet[City],cityChoice,tblLet[Status],statusChoice),deliveredCount,COUNTIFS(tblLet[City],cityChoice,tblLet[Status],statusChoice),IF(deliveredCount=0,"No orders",deliveredAmount/deliveredCount))
Check membership before arithmetic. If you keep the original four-row Pune count while adding only the three Delivered amounts, the formula returns a believable but incorrect ₹81. Names like deliveredAmount and deliveredCount give a reader a reason to demand the same rules in both places.

Simulate a corrected order status

Save a separate practice workbook copy so you can revert without guessing which cells were changed. Open the copy and confirm the formulas refer to its Table before you make an edit. If you instead copy Orders and Check inside the same workbook, give the duplicate Table its own name and update the copied formulas. A workbook can only have one Table of a given name, and a formula you copied may still intentionally refer to the original.

Change BLK-1009 from Cancelled to Delivered in the test copy. Assume this is a correction approved in the fictional source system. The four Pune amounts are now all Delivered. The status-specific average becomes ₹136 while the original all-status average stays ₹136. The two measures agree because their input populations agree. Check the opposite direction by restoring Cancelled. You should get ₹108 again in the Delivered result.

  • The source total across cities stays ₹2,870. Updating a status did not edit an amount.
  • The Delivered total increases from ₹2,215 to ₹2,435. It gained exactly ₹220.
  • The Cancelled total decreases from ₹460 to ₹240. It lost the same ₹220.
  • The Returned total stays ₹195. The three subtotals still add to ₹2,870.

That reconciliation gives you evidence beyond a plausible looking average. An interview answer that says “I know it’s right because the formula has LET” lacks that evidence. A useful two-line handoff names the membership rule and states a change with a predictable effect.

Extend the Table and check the business rule again

Start from a separate clean copy with original statuses. Add BLK-1011, Pune, 367, Delivered to the first new Table row. Confirm the Table includes it using the filter menu or Table Design boundary. Check whether both formulas point at this copy. Now the all-status Pune total is ₹911 for five orders, average ₹182.20. Delivered Pune contains four rows with ₹691, average ₹172.75. Across cities the full source total becomes ₹3,237. The difference between the averages remains because the original ₹220 Cancelled row remains outside the Delivered calculation.

LET did not cause the range to grow. Both formulas referenced Table columns whose boundaries grew. If you tried the same exercise using a hardcoded ten-row range, that range would still cover ten rows. This distinction matters when you develop a formula on a static practice sheet and later place it in a bigger report. Test growth with a recognizable row whose expected contribution is easy to isolate.

Refactor a repeated expression safely

Suppose a designer wants an ordinary-language status above the monthly orders. Enter a number in Q2 as a fictional city target, with 500 as a first test. In the old formula you see the city sum twice. One copy compares it with the target and one copy subtracts the target. A future edit to one occurrence could make the word and the amount disagree. Try the two versions in different empty cells and use the same controls.

=IF(SUMIFS(tblLet[Amount],tblLet[City],$M$1)>=$Q$2,"At or above target by "&(SUMIFS(tblLet[Amount],tblLet[City],$M$1)-$Q$2),"Below target")
=LET(cityChoice,$M$1,targetAmount,$Q$2,cityAmount,SUMIFS(tblLet[Amount],tblLet[City],cityChoice),IF(cityAmount>=targetAmount,"At or above target by "&(cityAmount-targetAmount),"Below target"))
  • With the original Table, Pune and target 500, both versions state At or above target by 44. The city amount ₹544 is used in both decisions.
  • Set the target to 544. Both state At or above target by 0. That text reveals use of an inclusive comparison.
  • Set the target to 545. Both state Below target. These two adjacent inputs test the boundary that a vague sample often misses.
  • Set Delhi and target 0. Both versions produce the target-met message, because a sum with no matching rows is zero. Ask whether a page with no observations should ever show target met. If the owner says no, add the separate row-count guard as a new rule and test the change deliberately.

The formula returns text, convenient for a sentence in a worksheet. If you also want to sort cities by the size of the gap, return the numeric difference in a separate column. A label beginning with a word cannot sort as a numeric amount. Put the currency symbol in a number format on the numeric field rather than embedding it in a text result that a second report will need to parse.

Debug a LET formula stage by stage

A formula can fail to enter, calculate an error, or show an unexpected but valid value. Mark which case you see before changing anything. Save or copy the original formula to a scratch location. Keep the source inputs and expected result visible while testing. Each fix below isolates a different cause so that you can explain what was wrong afterwards.

Excel rejects the formula before it calculates

  • Check the name positions. Read the arguments in order as name, value, name, value, result. A text label such as "cityChoice" belongs in a value expression if it really is a text label. The name being assigned goes in the name position without quotes. Use words such as cityChoice that start with a letter and do not look like a cell address. The short name c conflicts with Excel's R1C1 reference convention.
  • Find the final expression. After the last binding you still need to say what to return. Read =LET(orderCount,4,orderCount) aloud as “bind four to orderCount, then return orderCount.” An unfinished list of names and values has no result instruction. Microsoft documents a limit of 126 name-value pairs per LET. Most beginner formulas are easier to review with a handful of carefully named stages.
  • Separate levels of punctuation. The commas inside a SUMIFS belong to that inner function. The comma after its closing parenthesis separates outer arguments. Start with =LET(cityChoice,"Pune",cityChoice). After it works, add one new binding, and return that binding. If your Excel uses a semicolon as separator, follow your installation's normal delimiter convention.
  • Verify version separately from typing. Look for LET in function autocomplete or try =LET(testAmount,5,testAmount+1). Microsoft's catalogue identifies it as an Excel 2021-era function. An edition that predates it may be unable to recalculate this workbook. Confirm support for any other newer function used inside the same formula too.

The formula enters but the result is an error

  • For a misspelled binding, compare the exact names. If you assign matchCount and ask for matchesCount as the final result, Excel may report an unknown name. In a long report keep names distinct and consistently spelled. Return one of the bindings in a scratch copy to prove it resolves before returning a calculation that uses it.
  • For division by zero, look at the denominator. In Lab 1 inspect the relevant COUNTIFS. For Delhi it is zero, so the correct report branch gives a useful message. Selecting Pune with all amounts zero still yields four records. Returning a generic “No data” for both cases would hide real information.
  • For FILTER errors, inspect the included tests and alignment. If the source covers six orders, every Boolean column used in the row mask must refer to those same six records in the same order. Error values in a condition can prevent FILTER from evaluating the list. Return keepRows in a clean scratch area with enough free rows, then compare its first and last entries with their visible source IDs.
  • For a spill error, inspect the output range. LET may return a single amount during a debug test and a five-column report once restored. Leave enough rectangular space beside the report anchor. A neighboring cell containing data or another array result occupies space even if you intended it to be a visual label. Clear only the known blocker in the practice copy or relocate the report.

The result is valid Excel but answers a different question

A valid result is a value Excel can compute. A correct result is the value your audience needs under the stated rule. A city report in one pilot showed ₹81 because the numerator filtered by city and status while the denominator filtered only by city. A successful spill validated the rectangle, not which orders it contained. To review a report, list three examples with known outcomes. Include one record exactly at a threshold, an excluded status, and an input with no eligible records.

Check whether an absolute reference like $M$1 is intentional. If you copy the report down to test several cities and still point at M1, the repeated number is normal. If the design uses city choices in M5, M6 and M7, the input reference should follow the corresponding row instead. Keep the definition of the Table column constant. In ReportLab, anchoring H2 and H3 serves the opposite purpose. There is a single visible set of controls, so all report outputs should read those same cells.

Return intermediate values only in a scratch formula. A report may contain several dependent formulas expecting a certain shape. If a diagnostic returns a taller mask where the report expected a one-cell number, you can introduce a new spill conflict and lose the original evidence. Name the test sheet, label its input, and keep it out of any production lookup range.

Quiz with explained answers

What value comes back from LET when orderCount is assigned 4 and the final calculation is orderCount times 10?

40. The assignment records four in the local name. The final expression multiplies the stored value by ten, so the return value is neither the word orderCount nor the raw assigned four. You can test the stages by first returning the name alone and then restoring multiplication.

All four Pune orders have correctly recorded zero amounts. What average should the original report show?

Zero. Four rows qualify and the sum is zero, so there is a defined average of zero. Delhi has no qualifying rows, so it returns the distinct message. A reliable guard checks the denominator or membership before it calculates an average.

Why does ₹324 divided by four give the wrong average in the revised report?

₹324 is the Delivered Pune amount from three records. Four counts Cancelled as well, so the populations do not match. With the same rule in both calculations you divide by three and get ₹108. Compare the IDs in the two populations to prove the issue.

Which order ID remains if the report selects Nashik, Delivered, and more than twelve minutes?

SW-36. SW-32 has Nashik and Delivered but took only eight minutes. SW-36 is Nashik and Delivered with fifteen minutes, so all three tests pass. It appears once in the five-field result and contributes ₹260.

Why should the result of a temporary debug formula end with keepRows?

That makes Excel return the membership mask instead of the usual report, so you can see which records pass in their source order. Compare the known cancellation and threshold boundary to their positions. Keep the diagnostic in a free range. Its shape is a single column with one entry per source record.

What happens to the old fixed-range report when you type a new order after its last included source row?

It still reads its previous fixed range. A LET binding records that same range. To make the append part of the calculation, extend the reference or use the Table's structured column and verify the Table includes the appended row. Use a known ID and calculate its expected amount contribution independently.

Interview questions you can answer from practice

What is the difference between LET and a workbook named range?

LET names a value within one formula. For example, cityChoice can represent the current M1 inside a single calculation. A defined range name such as CampaignTarget can be visible to other formulas according to its scope. If several cells must share the same input, give them the same deliberate reference. Use a local name to make stages inside an individual formula clear.

How would you improve a bulky formula that runs the same FILTER twice?

First write down the table, the exact row condition and the intended no-match result. Bind the repeated filtered array under a descriptive name such as filteredRows. Return that result or reuse it in the final expression. Compare the old and new versions on ordinary matches and none, then add a record. Preserve output columns and sorting while changing how you organize the calculation.

How do you prove a misleading average is wrong without debugging every function?

Name one row that belongs to the numerator and one that must be excluded. For the Delivered Pune example, verify ₹64, ₹110 and ₹150 are included and the Cancelled ₹220 is excluded. Check that exactly three rows contribute to both the total and the count. You can narrow the problem to whichever formula used the wrong population.

Would you replace separate helper columns with one LET formula in every workbook?

Choose based on who needs to inspect the stages. A short report formula can name a subtotal and a count clearly. A quality-control field used throughout a finance workbook may deserve a visible helper column with a documented rule. Other people can then filter and audit that column. An agreed input convention and a reproducible check are more useful than saving one worksheet column.

What performance promise can you make after introducing LET?

A repeated expression assigned once can be reused by name within that formula. That can reduce repeated calculation. You should measure the old and new versions on representative data before promising a time saving for a whole workbook. Appreciate clarity first: point to the common expression, identify its meaning, and show that the output and boundary cases stayed correct.

Revision cards

  • Bind, then return. Read the argument pairs as a short recipe. Treat the last argument as the result instruction.
  • A local name stays local. A second cell needs its own calculation or a deliberate shared reference.
  • Name the business rule. An amount for Delivered orders needs a count for Delivered orders before division.
  • Zero and no rows differ. Zero can be a useful measured result. Check the number of records before averaging.
  • Debug one stage. In a scratch copy, return the binding whose value or shape you want to inspect.
  • Test at the boundary. Include a normal match, an exact threshold, an excluded type and an empty population.

Microsoft references