view source

Excel and Google Sheets Charts and Dashboards

skill

Build charts, sparklines, slicers and dashboards inside Excel or Google Sheets, or generate a workbook with charts from Python. Use for sheet dashboards.

Apache-2.0 Excel for Microsoft 365, Excel 2021 and older, or Google Sheets. The Python workbook step needs Python with uv, or the xlsxwriter package.

agents that use this skill

instructions

Overview

Use this skill when a chart, sparkline or dashboard is built inside Excel or Google Sheets, or when a workbook with charts is generated from Python. The outcome is a workbook where each chart answers one question, still works after rows are added, and can be handed to someone who was not there. Formulas, lookups and pivot table setup are a separate job: this skill starts once the summary range exists or is being designed. The deliverable is the file or a numbered step list, checked by changing the data and looking at the result.

Mental model

  • A dashboard has three layers: source data, a summary range, and the charts. Keep them on three sheets, Data, Calc and View. The FAST Standard separates worksheets by type in the same way: foundation sheets with the inputs, workings, and presentation. Charts read Calc; nobody types numbers on View.
  • Source data is one list: labels in the first row, the same kind of item in each column, no blank rows or columns inside it (Microsoft, data organization guidelines), and no merged cells (UK Analysis Function). Leave at least one blank row and one blank column between it and other data (same page).
  • A chart draws a range. If the range does not move with the data, the chart goes stale without any error.

Rules

Match the feature to the app

FeatureExcel (Microsoft 365, 2024, 2021)Google Sheets
Summary that follows the dataDynamic array formulas spill into the cells below; they are not supported inside an Excel table, so put them in the plain gridQUERY (select, where, group by, pivot, label) and FILTER, which returns #N/A when nothing matches
Pivot summaryPivotTable, then PivotChartPivot table; filter with a Filters field in the editor
Filter controlSlicer; Timeline for a date fieldSlicer (Data, Add a slicer)
Cell-sized chartSparklines: line, column, win/lossSPARKLINE function: line (default), bar, column, winloss
In-cell barsConditional formatting, Data BarsSPARKLINE with charttype bar

Older Excel shows dynamic array formulas as legacy array formulas that do not resize. Run the Compatibility Checker before sharing a workbook with people on older versions. Excel slicers for tables and data model PivotTables need Excel for Windows or Mac; Excel for the web creates only local PivotTable slicers. Timelines need a date field in a PivotTable.

Pick the chart from the reader's task

Reader's taskExcel and Sheets nameCondition
Compare categoriesColumn; Bar when labels are longClustered, not stacked, unless totals matter
Trend over timeLineNot a stacked line: it sums the data, which can mislead
Share of one wholePieOne series, no negative values, at most seven categories (Microsoft)
Two numeric measuresScatter (XY)Uneven spacing or many points
Series with different formsComboColumns for amounts, line for a rate
Change over time and totalAreaNon-stacked areas can hide a series; use lines instead

Recommended Charts (Insert, Recommended Charts) proposes a chart for the selected cells, and Alt+F1 inserts one at once. General chart form and colour decisions follow the data-visualization guidance; this skill covers the app.

Remove default clutter

In Excel use Chart Design, Add Chart Element to switch off or move the title, axis titles, legend, gridlines and data labels. In Sheets use the Customize tab. To hide gridlines but keep axis labels in Sheets, give the gridlines the chart background colour. Delete the legend for a single series, and put the message in the title.

Make ranges grow with the data

  • Excel: a chart pointed at a fixed range ignores new rows. Define names that resize, for example =OFFSET($B$2,0,0,COUNTA($B:$B)-1), and enter the names as the series values and category labels with the sheet name, for example =Sheet1!Sales. Microsoft's page gives the full steps. COUNTA counts formulas and stray entries in the column, so keep the column clean.
  • Sheets: a pivot table is drawn from its Select data range; after rows are added outside that range, change the range in the pivot table editor. For the chart, open Setup, Data range and extend the range. QUERY and FILTER output feeds a chart range that has room to grow.
  • Every case ends with a test: append one row of dummy data, confirm the chart took it, then delete the row.

Slicers, timelines, sparklines, data bars

  • Excel: a slicer connects only to PivotTables that share its data source; use Report Connections or Slicer Settings to attach more.
  • Excel: a timeline filters on a date field and switches between years, quarters, months and days. To use a slicer and a timeline on the same date field, turn on Allow multiple filters per field in PivotTable Options.
  • Sparklines have a custom axis minimum and maximum; by default Excel determines the scale. Set the same custom values on rows that are compared. Choose how empty cells show: gaps, zero or connected, and whether hidden rows count.
  • Sheets: a slicer filters the charts and pivot tables on its sheet that use the same data set, not formulas.
  • Data bars take their scale from Lowest/Highest Value, Number, Percent, Percentile or Formula. Percentile limits the influence of extreme values, so use it when one outlier would flatten the rest.

Generate a workbook from Python

XlsxWriteropenpyxl
Writes new filesYesYes
Reads or modifies existing filesNoYes
Chartsline, column, bar, pie, doughnut, area, radar, scatter, stock; no 3DIncludes bubble and surface
SparklinesYes (Excel 2010 or later)Dropped when a workbook is loaded, so saving an edited file loses them

For a new workbook with charts, use XlsxWriter. Use openpyxl only to edit an existing file, and reopen the result to check that charts survived. Write the source as a table with add_table, build the summary on Calc, and point each series at a Calc range. Run it with uv run --with xlsxwriter python script.py:

text
import xlsxwriter

rows = [
    ["Jan", "East", 10], ["Jan", "West", 8],
    ["Feb", "East", 12], ["Feb", "West", 9],
    ["Mar", "East", 15], ["Mar", "West", 11],
]
wb = xlsxwriter.Workbook("out.xlsx")
data = wb.add_worksheet("Data")
calc = wb.add_worksheet("Calc")
view = wb.add_worksheet("View")
data.add_table("A1:C7", {"name": "Sales", "data": rows, "columns": [{"header": "Month"}, {"header": "Region"}, {"header": "Revenue"}]})
calc.write_row("A1", ["Month", "East", "West"])
for i, month in enumerate(["Jan", "Feb", "Mar"], start=2):
    calc.write(f"A{i}", month)
    for col in "BC":
        calc.write_formula(f"{col}{i}", f"=SUMIFS(Sales[Revenue],Sales[Month],$A{i},Sales[Region],{col}$1)")
chart = wb.add_chart({"type": "line"})
chart.add_series({"name": "=Calc!$B$1", "categories": "=Calc!$A$2:$A$4", "values": "=Calc!$B$2:$B$4"})
view.insert_chart("A1", chart)
view.add_sparkline("H2", {"range": "Calc!B2:B4"})
wb.close()

Check the file by reloading it with uv run --with openpyxl python -c "import openpyxl; wb=openpyxl.load_workbook('out.xlsx'); print(wb.sheetnames, len(wb['View']._charts))". openpyxl drops sparklines when it loads a workbook, so a reload cannot confirm them: open the file in the spreadsheet app, or find the sparkline group in the worksheet XML inside the xlsx (unzip -p out.xlsx xl/worksheets/sheet3.xml | grep -c sparklineGroup). Formula cells hold no computed values until Excel opens the file, so read the numbers in the app, or pass the value argument to write_formula.

When the user cannot be asked, assume Microsoft 365 or current Google Sheets and say so.

Examples

Fixed range to growing range. Bad: a line chart on A1:B13; the January row added later never appears. Good: names defined with OFFSET and COUNTA drive the series, and a dummy row proved the chart extends.

Chart on raw rows to chart on a summary. Bad: a column chart on 3,000 transaction rows. Good: a Calc sheet with one row per month and one column per region, and the chart reads that range.

Ten charts to one column. Bad: ten tiny line charts, one per product. Good: one sparkline per row beside the table, sharing one axis maximum so the rows compare.

Output format

  • Workbook path or sheet link, and the sheets with their roles.
  • Each chart with the range it reads and the question it answers.
  • The app and version assumed, and the one test done (the dummy row).

Checklist

  • App and version are stated; no feature outside that version is used.
  • Data, Calc and View are separate; the source is one list with no merged cells.
  • Each chart name matches the reader's task; pies have one series and at most seven categories.
  • Title, legend, gridlines and labels were set on purpose.
  • A dummy row was added; the chart, pivot and sparklines took it; the row was removed.
  • Slicers and timelines are connected to every PivotTable they must filter.
  • A generated file was reopened; its sheets, charts and sparklines exist, and numbers were read in the app.

Composition / References

Scope limits: formulas, lookups, cleaning and pivot table building are a separate job; statistics, general chart form and colour, and charts for web applications are others.