8.14 Drop-down Driven Dynamic Chart (INDEX / XLOOKUP)
1. Let one selection change the numbers and the title together
A manager wants to choose Pune, Nashik or Nagpur from one cell and review that city's sales across the same six months. Creating three separate charts makes it easy for one to use a stale label or a different time span. A drop-down can control one chart when formulas return the selected series to an inspectable helper range. Keep the source table, control, helper values and title as separate parts of one deliberate chain.
Think of a fictional store report inspired by switching locations in an app such as Swiggy. The sales figures are practice data and describe no actual company. We will check all six numbers for Nashik, switch to Nagpur, then reproduce the selection with functions available in earlier Excel versions. The chart will read the same helper cells before and after the switch. If the source later adds a seventh month, that is a separate test.
One selection, one verified record scope. When the chosen city changes, check the helper values, chart and title together. When no city is valid, show that state explicitly.
Separate the role of each part
- Source matrix. Rows represent approved months and columns represent cities. One cell supplies an amount for one month and city. Keep labels and numeric values together.
- Selector. Data Validation offers approved city choices in a cell. The selection is an input to the calculation. It does not alter the source table.
- Helper range. A small fixed row or column returns just the selected values. Its category labels have the same count and order as these values.
- Chart and title. The chart reads the helper. A title or visible scope cell describes which city it currently shows and what the numbers measure.
- Control checks. Check a known month, a total, and a bad-selection state so you can detect both the wrong source and the wrong claim.
Test the helper by reading its six returned numbers before inserting a chart. Once the helper is correct, chart repair is a smaller task. If the helper shows Pune but the chart looks like Nagpur, inspect the chart's selected series. If the chart updates but its title says Pune regardless of the selection, inspect the title reference. Separating those checks makes the issue easier to locate.
2. Prepare matching period and location labels
Goal. Build the original practice source with verified six month rows and three city columns. On a sheet called ChartData enter A1:D7. Month cells are actual first-of-month dates, entered with DATE as needed. Display them with a suitable month and year format. Sales amounts are numeric lakh rupees. Keep all month dates unique and all city column labels unique for this exercise.
| Month start | Pune | Nashik | Nagpur |
|---|---|---|---|
| 2026-08-01 | 3.1 | 1.8 | 1.6 |
| 2026-09-01 | 3.4 | 2.0 | 1.7 |
| 2026-10-01 | 4.2 | 2.3 | 2.1 |
| 2026-11-01 | 5.6 | 3.1 | 2.9 |
| 2026-12-01 | 4.8 | 2.6 | 2.4 |
| 2027-01-01 | 4.1 | 2.2 | 2.0 |
Build a simple list on the selector's own sheet
On a new sheet named Dashboard put the three approved choices vertically in J2:J4. You can reference the ChartData headers individually to keep the choices consistent with them. Keep three valid unique choices, with no leading or trailing spaces. Select B1 and create a Data Validation List using =$J$2:$J$4 as Source in supporting versions. Turn on the in-cell drop-down if the option is exposed. Choose a Stop alert for invalid typed values where available and select Nashik to start.
A validation list helps a user choose spelling consistently. It does not supply a matching record in an unrelated lookup array. Check which cells the list uses and which headers the formula searches. A pasted or externally supplied value and a changed source can still create a mismatch. Test what the helper does when the selection is not valid. Put the helper and a visible status cell on the same workbook copy so the chart cannot quietly show data from the previous valid choice.
3. Lab. Use nested XLOOKUP to populate one selected row
Follow one city choice into the chart
Prepare six real period labels
Put the given month-label formula in B3 and fill across through G3. It reads the source dates in order, beginning in August 2026 and ending with January 2027. Format the six cells to make that year boundary clear.
Count matching city headers
Use the displayed control in J6. Nashik should match exactly one approved header. The match test uses Excel's usual case-insensitive equality rather than a wildcard search. If no unique match is present, the value helper should not show a numeric series.
Find the selected series and one period within it
Use the nested XLOOKUP in B4 and fill across through G4. The inner lookup returns Nashik's six-value source column. The outer lookup reads the month in the current helper column and returns one value from that column. The expected November result is 3.1.
Build the chart from the helper only
Use B3:G3 for category labels and B4:G4 for the single series. If inserting from a two-row range uses a different orientation, adjust Select Data or the appropriate series controls. Verify there are six categories and one series.
Switch the city and check the title
Use B2 as the visible title helper. Link the chart title to B2 where supported. Change the selection to Nagpur. November becomes 2.9 and October becomes 2.1. The title and scope should say Nagpur. Keep the helper visible for checking.
Dashboard B3 =INDEX(ChartData!$A$2:$A$7,COLUMNS($B$3:B3))
Dashboard J6 =SUMPRODUCT(--(ChartData!$B$1:$D$1=$B$1))
Dashboard B4 =IF(AND($J$6=1,SUMPRODUCT(--(ChartData!$A$2:$A$7=B$3))=1),XLOOKUP(B$3,ChartData!$A$2:$A$7,XLOOKUP($B$1,ChartData!$B$1:$D$1,ChartData!$B$2:$D$7)),NA())
Dashboard B2 =IF($B$1="","Choose a city",IF($J$6=1,$B$1&" · monthly sales (₹ lakh)","Review city selection"))
Use these formulas with the named sheets and addresses shown. Enter the formula after the address label, starting from the equals sign. The two exact-match controls deliberately check city and month uniqueness. This first lab expects every approved amount cell to be numeric and complete. The next lab shows a status-aware alternative for missing inputs. XLOOKUP is available in current supported versions and Microsoft documents that Excel 2016 and 2019 do not have the function. If your build does not have it, proceed to the next lab's worksheet functions.
4. Lab. Verify a compatible INDEX and MATCH version with missing-value checks
Goal. Rebuild the same selector using INDEX and exact MATCH, with separate checks for city, month and numeric source. Make a copy of Dashboard called DashLegacy. The examples here use its same cell addresses. The original ChartData sheet stays the common source. Keep the six helper dates and the same approved drop-down choices on the copy.
- Make numeric status checks for the matrix. On ChartData, use F2:H7 for Boolean flags. In F2 type the shown formula and fill right through H2, then down to row 7. F corresponds to B's Pune data, G to C's Nashik and H to D's Nagpur. A numeric source cell has a TRUE flag. An actual empty cell or text amount gives FALSE.
- Find the correct position. In DashLegacy K6 compute the city column index only if J6 says one city matched. With Nagpur selected, K6 should be 3. In B5:G5 compute the month row indexes after confirming each has exactly one match. For October, the month row index is 3.
- Return the crossing row and column. In DashLegacy B4 use the INDEX helper below and fill across. INDEX takes the numeric matrix, one row index and one column index. The source status grid supplies a check at the same position. For Nagpur and October, the 3rd data row and 3rd city column contain 2.1.
- Test an unavailable amount. On a disposable copy of the whole workbook, select Nashik in DashLegacy and clear its November source ChartData!C5. Its status grid output is FALSE. The helper returns #N/A for that period, leaving only five verified numeric readings. Inspect the actual chart's display behavior. Keep a scope note that reports the missing value.
- Test the full scope and recover. Restore the November amount. Select all three cities in turn and check their total, latest month and peak. Use the exact fixture values and verify the linked title or visible status changes together with the chart.
ChartData F2 =ISNUMBER(B2)
DashLegacy K6 =IF($J$6=1,MATCH($B$1,ChartData!$B$1:$D$1,0),0)
DashLegacy B5 =IF(SUMPRODUCT(--(ChartData!$A$2:$A$7=B$3))=1,MATCH(B$3,ChartData!$A$2:$A$7,0),0)
DashLegacy B4 =IF(OR($K$6=0,B$5=0),NA(),IF(INDEX(ChartData!$F$2:$H$7,B$5,$K$6),INDEX(ChartData!$B$2:$D$7,B$5,$K$6),NA()))
Complete selected total =IF(COUNT(B4:G4)=6,SUM(B4:G4),"Incomplete")
Read relative and absolute references in the helper row
When you fill B4 through G4, the raw ranges use dollar signs so they stay fixed. The city choice always reads B1. The month label B$3 keeps its row while the column advances, so each output cell fetches its own period. In the earlier formula that prepares the labels, COLUMNS counts the width of a reference that starts at a fixed B3 and ends at the current column. It yields 1 through 6. Check those positions if a filled range returns the same month six times.
Exact MATCH with a zero match type returns a position among the supplied cells. The source label guard uses ordinary equality so a newly typed unknown value cannot silently fall back to a nearby city or match a wildcard. The source fixture uses ordinary approved city names and unique actual dates. For a repeating real-world label across regions, introduce a verified unique location key and present a friendly display label separately. A single location name may not be sufficient as a key.
Check all three cities against exact results
| Selection | October | November | January | Six-month total |
|---|---|---|---|---|
| Pune | 4.2 | 5.6 | 4.1 | 25.2 |
| Nashik | 2.3 | 3.1 | 2.2 | 14.0 |
| Nagpur | 2.1 | 2.9 | 2.0 | 12.7 |
The highest period for all three cities is November in this fixture. An optional check can return the matching date with INDEX and MATCH, using a verified complete helper. For one row of six headers, supply row 1 and a matching column index. An exact match to a maximum can return one of multiple equal maxima, so summarize all tied periods if the question requires that.
=IF(COUNT(B4:G4)=6,INDEX(B3:G3,1,MATCH(MAX(B4:G4),B4:G4,0)),"Review periods")
Format the result as a date if you show the peak month. In an incomplete test selection, COUNT can report fewer than six even when an error appears in the helper. Guarding SUM and MAX with that check prevents a false complete result and avoids reporting a missing month as zero. Use the status text and source grid to explain exactly which values are missing rather than reading only Incomplete.
5. Make invalid and missing selections visible
Handle empty, unknown and duplicated inputs deliberately
On a disposable copy, clear the selector. The title cell says Choose a city. Without one unique city, the numeric helper should show no valid series under its error-marker convention. Use a separate status text if your chart draws unwanted marks for errors or empty results. To test a new unsupported text value safely, use a disposable copy with a test input and available validation controls. You can temporarily change or disable its validation on that copy, then enter a city not supplied in the approved matrix. The title should say Review city selection instead of claiming a known series. Restore validation and a proper choice.
Now imagine duplicate headers both named Pune. In an ordinary range Excel can have duplicate header text. A lookup without a uniqueness check can choose the first match, which may hide the duplicated definition. J6 should count two matches in that copied source and reject the current selection. Confirm it fails before either lookup resolves. When the source is an Excel Table, header names must be uniquely assigned; use the same business-level check where labels or keys can still introduce ambiguity.
Month labels need their own checks. A source might contain November from two years in a longer matrix. Text Nov alone will no longer uniquely identify the intended row. Real first-of-month dates help separate 2026 from 2027. Pair them with the approved period window and match exactly. If the new report measures weekly values instead, update both ChartData and the helper category period contract rather than only changing the visible labels.
Explain the #N/A display without promising its exact shape
The helper uses #N/A intentionally for missing or unapproved values. This is an error marker for reporting, not a valid numeric amount. Excel chart behavior for #N/A and missing cells varies by version and chart type. Check whether the actual line omits the point, connects a gap, or uses another rendering rule. If the chart cannot communicate the intended undefined state, give the exact table and a clear No verified series or missing-period note. A helper or status that writes zero for every missing source would erase the distinction.
The original complete XLOOKUP lab assumes every source numeric cell is validated. Lookups can display misleading zero-like results when a referenced source cell is blank. Do not infer completeness from a returned zero alone. The second lab's explicitly checked numeric matrix exists for that reason. If you keep the modern formula in production, apply equivalent source validation or a checked mask before plotting. Test a truly numeric zero as a separate input so the guard still lets valid values through.
6. Keep the selected chart, title and summary in sync
Link the correct text or keep a verified caption nearby
On a supporting desktop chart, select its title as a chart element. Click the formula bar, type an equals sign and select the sheet cell containing the calculated title. Press Enter and verify the connection by choosing a different city. On Dashboard the intended reference is its B2 cell. On DashLegacy verify the copied chart title points to that sheet's B2 if you are using an independent chart. Repeating the visible text manually does not maintain a link. If your app does not expose a linked title control, put B2 beside the chart and make the chart's generic heading describe monthly sales and units.
Verify the chart's single plotted series. In the intended setup the values come only from the six helper cells, and the labels from the corresponding six month cells. Check a resume case by saving a temporary copy with Nashik selected. Reopen it in the intended Excel version and switch to Pune. The total should become 25.2 and the November point should become 5.6. If only the title changed, the chart may still reference a source column directly or be a static pasted image. If only the values changed, inspect the title and legend text separately.
Change the city without changing the horizontal scale
The chart always covers August 2026 through January 2027 in these two lab sheets. A switch to Nagpur brings different values for each date but does not move January earlier or add a new period. A chart that changes its numeric axis automatically can make two different amounts appear at the same height across screenshots. The teaching figure uses a shared zero-to-four view only for the illustrated Nashik and Nagpur selections. When including Pune on the same comparison, use enough room for its November 5.6, for example a common zero-to-six range. Check both restored series and the domain. A fixed axis suitable for two eligible selections can still cut off another.
For a July-to-January report change, extend the intended period label and value ranges together. The displayed examples are six-wide by design and do not automatically add a period just because more rows appear in ChartData. When you add another city, extend or update the approved list, the lookup labels and returned matrix in compatible dimensions. An added option without a source column should be rejected. An added column without an updated list can stay inaccessible through the control. Treat each dependency as part of the acceptance check.
Try a diagnostic checklist in the right order
- Check the control. Is the city currently set to one approved option? Does its exact comparison produce one match? Verify the source list and entered name.
- Check the period labels. Verify both August and January dates and the six positions between them. The row converted to a text title should not change the actual input types used by the lookups.
- Check two returned values. Use Nashik November 3.1 and Nagpur October 2.1 on the intended selections. Confirm that a missing reading triggers the correct output without creating an apparent zero.
- Inspect category and values series. The chart should read the helper definitions. If labels are plotted as a second series, set the selected coordinates correctly and recheck the order.
- Check every caption or summary. A total based on the source's entire matrix will not follow the chosen city. Tie the sum to the verified helper and include partial statuses.
- Check a bad selection and recover. Show a meaningful status, verify that no stale valid summary remains, restore one approved value and recheck the plotted points and title.
Use the Excel Task Hub for more lookup practice. Write the intended control value and expected returned row before making a dynamic chart. Continue to Rolling Charts with OFFSET for a different dynamic behavior that changes a time window rather than choosing the city for a fixed set of months.
Apply the same numeric guard to the modern formula
Once the first lab is verified, try a copy of its modern helper that keeps all nonnumeric source entries marked as unavailable. The input matrix is still six rows by three columns. Create an expression that computes a mask across that matrix. ISNUMBER checks each real source value. IF leaves numeric amounts intact and replaces other inputs with an error marker. The inner XLOOKUP chooses the masked column, and the outer one chooses a month from it. The worksheet output is still one cell for each time period. Use this version only in an Excel build that supports the nested lookups and array expressions used here.
=IF(AND($J$6=1,SUMPRODUCT(--(ChartData!$A$2:$A$7=B$3))=1),
XLOOKUP(B$3,ChartData!$A$2:$A$7,
XLOOKUP($B$1,ChartData!$B$1:$D$1,
IF(ISNUMBER(ChartData!$B$2:$D$7),ChartData!$B$2:$D$7,NA()))),
NA())
Verify three states with the same selected Nashik month. First put the original 3.1 in ChartData!C5 and verify the complete total 14.0. Then on a work copy clear that value. The row has only five valid numeric readings, whose original amounts add up to 10.9, and the complete summary should withhold a total. Finally, enter a confirmed numeric zero into C5 as a teaching test. That time the count still reaches six and the sum is 10.9 with a true November zero. Those last two scenarios give the same sum of known values but do not have the same coverage. Restore 3.1 when the test is finished.
This is where the status column or message matters. A cell may display #N/A because the selected city is unapproved, the month repeats or the amount is missing. The workbook owner should see which control failed. Keep J6 for city matches, the separate month lookup check and the count of numeric helper cells. A complete numeric count with the wrong city is not enough, while a valid city may reasonably have a partial selection. Report enough context for the next person to repair the exact input.
Trace a mismatched date and examine the output dimensions
Take August 2026 as one known helper date. It should equal the actual date value in ChartData, not just look like the label Aug. Enter a text Aug in a temporary copy of one helper header and inspect its exact-match guard. It should fail because the source contains numeric month dates. The visible label and the stored type differ. Fix the type in the source or helper so they share the same representation instead of changing the lookup to an approximate match. Selecting nearby dates could hide the missing match.
Switch from August to November in the same test. The lookup array has six month rows. The selected city return array also has six rows. If you shorten one range but leave the matching dates at six, the arrays no longer have compatible shapes. Verify both starting and ending rows before deciding there is a calculation problem with XLOOKUP itself. In the older formula, check that the status matrix and amount matrix cover the same rows and columns, or a valid flag could test a different cell than the one actually returned.
You can audit the choices against literal cell positions. With Nagpur selected, check K6 equals three. November should have row position four and the amount at the crossing is 2.9. If you copy a source block and silently insert a district column among the city values, the old column index may point to a different field depending on the range and formula updates. Verify the headings and all relevant ranges after structural changes. A small check table for all choices is usually more useful than reviewing only the graph.
Add a verified combined option as a separate exercise
Suppose the manager later asks for All three. This is an explicit aggregate, not an unknown lookup key. Add a new column E to ChartData on a disposable copy, with All three in E1. For every month sum the three known city amounts only when all three are present. Because the exercise treats them as nonoverlapping amounts with matching units, adding them is appropriate. If a city reading is missing, mark the combined value incomplete rather than claiming the subtotal is for all three.
ChartData E2 =IF(COUNT(B2:D2)=3,SUM(B2:D2),NA())
Fill E2 to E7. The expected sequence is 6.5, 7.1, 8.6, 11.6, 9.8 and 8.3. The new option represents the verified combined sales series across all three cities. Its six-month total should be 51.9. Add All three deliberately to the allowed-list range and update the list reference to include it. Extend the matching header range from B1:D1 to B1:E1 and the return block from B2:D7 to B2:E7. For the legacy guarded helper, fill the flag grid right through I and extend its references accordingly. Verify the title and the chart axis. A chart configured for a peak of six before this change could clip 11.6 now.
Test the single-city and combined modes in both directions. Switch from All three to Pune and observe that October goes from 8.6 to 4.2. Switch back and verify only the intended helper and summary changes. If a city amount becomes missing, its own selected view discloses the missing month, and the All three view cannot use a numeric value for the same incomplete period under this rule. Source validity rather than the shape of a drop-down defines which output is approved.
Test the helper with an out-of-order source and a copied control
Move the full November row and its three amounts after December on a disposable worksheet. If the six helper dates are read directly from the source order, the chart category sequence also changes. The exact lookup still finds November's value, yet the display can be unchronological. Sort complete source rows by the actual date or supply a separately approved ordered date row. Then verify August through January in the intended sequence. A unique lookup key does not impose a chronological layout on categories by itself.
Make a second test where the workbook is copied to another sheet with a different choice. The original should still show its own control value. On the copy read the helper and title references before testing a second city. Some copied objects may retain dependencies on the first sheet. If the new copy displays the original city's data or title, reassign its ranges intentionally. Don't assume that changing the cell made a chart independent unless the actual definitions and resulting values show that it did.
You can check two states with specific instructions. Leave Dashboard at Nashik, select Nagpur on DashLegacy, and verify 14.0 and 12.7 separately. The two copies use the same source inputs but different selector cells. If either chart changes unexpectedly when you edit only the other selector, inspect the cross-sheet reference and its linked title. Both should still update when the shared ChartData values change. This tests both how the independence works and which shared dependencies remain intentional.
Try a change where February is added after the January column is already correct. Compare the new source row with the original six-helper chart. Its absence demonstrates a capacity limit. Leave two views clearly labeled if both are needed for review, with one frozen at January and the second extended to February. A genuine date alone cannot extend a fixed reference.
Version checks are part of the same workflow. Opening a workbook built with a newer XLOOKUP function in an older version may show unsupported formulas. Use the separate compatible build for those readers and verify all choices. A polished older screenshot cannot confirm that the formulas recalculate in that environment.
Make the chart readable when shared without the spreadsheet
On export, the drop-down itself may no longer be interactive and the chart may be a static image. Give that copy the visible selected name, exact period and units. A screenshot of Nagpur and November 2.9 should not be reused with a caption from the Pune trial. Save one checked state at a time and confirm the chart title and the printed values agree. If the workbook is intended to remain interactive, test it using the same client the next person will use, including whether data validation controls, formula versions and title links work there.
For accessibility keep a readable selected-state table near the chart. A written summary such as Nashik, six verified months, November 3.1 and total 14.0 supplies the most useful facts even if the graph is small. If the user chooses another option, update the summary based on the same helper instead of writing the numbers by hand. Keep a clear transition to a no-selection or incomplete state. A chart image with a clear title is useful, but an exact accessible result is easier to audit.
Distinguish a selection-driven report from adding or filtering rows
The two formulas in this lesson look up one of several columns for each of six fixed dates. They do not automatically shrink to the visible rows of the original table if someone filters the worksheet. A lookup can still read source cells under a filter. Define whether that is the desired behavior for the report. If a different control is meant to hide an entire series, keep that as a separate visibility rule instead of overloading the city key. If the task is to append periods, use a compatible range design and verify both axes. Selectors, filters and growth are different events even when each visibly changes a graph.
7. Interview questions with practical answers
How do you build a chart controlled by one drop-down?
Make an approved validation list and use the selected key to fill a short helper range. Point the chart's values and categories to the verified helper. Link or display the current scope. Test all options and at least one unsupported selection so the view does not show an old or invalid series.
What does the inner XLOOKUP return in this matrix?
It searches the horizontal headers for the chosen city and returns that city's vertical column from the six-by-three data block. The outer lookup uses the current helper date to find one numeric value from that column. The successful result has one value per helper month.
How would you support a version without XLOOKUP?
Use exact MATCH to find the city's column and month's row. Supply both positions to INDEX for the numeric matrix. Keep a source numeric check and an approved-key policy, just as in the current version. Test known values and ranges rather than comparing function names only.
Can Excel validation prove the source label has one matching result?
The allowed list controls choices in a cell. A separate comparison checks whether the selected key has one matching header in the current source. A new option may be missing or duplicated in the matrix. Verify the actual lookups and show status for an invalid result.
How would you handle an unavailable month without inventing a zero?
Confirm the original cell is numeric before passing it to the chart. Mark a missing source separately and check the target chart's display of the error marker or supplied missing representation. Keep a visible scope note and a verified numeric count. A genuine numeric zero remains valid.
8. Predict the selected series before changing the cell
What should the Nashik helper show for November?
3.1 lakh. The city column is Nashik and November is the fourth month of the six-row matrix. Verify the same label in the chart title or nearby scope text.
What exact total follows when you select Pune?
25.2 lakh across the six given periods. The total depends on the selected helper's complete numeric values rather than the entire matrix.
What should happen if a requested city has two identical source headers?
The unique match check should reject it for review. A lookup could otherwise choose the first matching column, hiding the duplicate business definition.
Will the six helper positions automatically add February when the source gains a month?
The given helper is fixed at six positions and its source references are fixed. Extend or redesign the source and helper and verify both the category and values series before making a seven-month claim.
What labels can remain stale when the drop-down works?
The manually typed title, series key, KPI or date scope can still describe a previous city. Change one selection and verify each label and exact point separately. Keep a visible valid or incomplete status.
9. Six reminders
- One control, one key.
Keep the approved list and source names aligned and unique.
- Verify both positions.
Choose the right city column and period row before taking a value.
- Keep the helper inspectable.
Make one clear source for the chart and keep exact readings available.
- Check chart and title separately.
A correct data switch can still leave stale scope text.
- Preserve missing states.
Review bad keys or missing readings without inventing measured zeros.
- Change source extent deliberately.
A city selection does not add periods or automatically correct a new source dimension.
Microsoft references
- Data Validation list and error alerts
- Update source options in a validation list
- Nested XLOOKUP and version limits
- INDEX with row and column positions
- Exact matching and position results
- Chart title linked to a cell
- Inspect the source of the selected chart series
- Missing-value chart settings and scope