Power BI technique · built-in features only
How to add sparklines to a Power BI table or matrix
By Nawaf Sharaf · Founder & Reliability Engineer · Updated
When to use it. Use sparklines when each row needs its own trend next to its numbers (product, store, account). For one big trend, a line chart is clearer.
Worked example
Worked example · Wren & Vale · one sparkline per product (each row on its own scale)
| Product | Sales (12 mo) | Dec vs Jan | Jan → Dec |
|---|---|---|---|
| Linen notebooks | $568,800 | +39.9% | |
| Fountain pens | $229,500 | +10.9% | |
| Desk planners | $99,300 | +145.9% | |
| Ink refills | $14,720 | +11.6% |
Wren & Vale is a fictional stationery brand. Each product row has a twelve-month sparkline with green and red markers on its highest and lowest month. Desk planners fall to their low in June and then climb for the new year, ending +145.9% on January. Linen notebooks grow steadily (+39.9%), fountain pens drift up (+10.9%).
Ink refills look as lively as the others, but the whole line moves within a $200 range over the year. Each sparkline scales to its own row, so a tiny product and a big one draw lines of the same height. That is why the table keeps the Dec vs Jan column next to the sparkline: the line shows the shape, the number shows the size.
Steps
- 1
Open the sparkline dialog
Select the table or matrix → in the Values well, open the measure's dropdown → Add a sparkline.
- 2
Choose the measure and axis
Y-axis: the measure (Sales). X-axis: a date field at the grain you want (month is common).
- 3
Format it
Format visual → Sparklines: choose line or column, colour, and markers (highest, lowest, first, last) so the extremes stand out.
- 4
Keep rows comparable
Each sparkline scales to its own row, so shapes compare but heights don't. Put the actual values or a % change next to it.
How it works
A sparkline is a small chart of a measure over a second field, drawn inside each row. Power BI evaluates the measure for each value of the x-axis field within the row's filter context, which is why a product row's sparkline only shows that product. The summarisation you choose in the dialog (sum, average, and so on) is applied per x-axis point.
The y-scale is per sparkline, chosen from that row's minimum and maximum. This is what makes shapes comparable across rows and absolute sizes impossible to compare by eye. Markers for highest, lowest, first and last points make the extremes readable without labels.
The x-axis field sets the grain. Power BI draws at most 52 points per sparkline, so a daily date cuts the line short; a month column gives twelve clear points.
What Microsoft documents
Limits and behaviour from Microsoft Learn that change how you build this.
- Microsoft's steps start from the table or matrix itself: open the dropdown arrow next to a numeric field in the Values well and choose Add a sparkline. The dialog pre-fills the y-axis with that field and its summarisation; you choose the x-axis field, usually a date or month column. Edit sparkline on the same menu opens the Sparklines card in the Format pane, where you set line colour and width, add markers (highest, lowest, first, last), and switch from line to column style.
- The documented limits: up to five sparklines per visual and up to 52 points per sparkline. With sparklines on, a matrix is limited to 25 columns. Visuals with sparklines can't be pinned to a dashboard. Sparklines work on Azure Analysis Services but not on on-premises SQL Server Analysis Services.
- If the model has calculation groups, the sparkline dialog lets you apply them to Individual values (the default) or to the Entire sparkline; an item that does arithmetic is not supported in the second mode.
- Microsoft's page still describes sparklines as a preview feature, so check the formatting options against your Desktop version before you write instructions for colleagues.
Variations
- Column-style sparklines read better for counts with gaps (orders per week); line style is better for continuous measures.
- For a target band or a shared scale across rows, an SVG measure can draw what the native sparkline doesn't.
Check that it works
Compare one row's sparkline with a line chart of the same product filtered to the same months: the shape should match point for point. Count the points on the longest row; if a weekly x-axis has more than 52 values, the line is cut, so switch to month or filter the period. Last, check the highest and lowest markers land on the months the table's own numbers say they should.
Common mistakes
- Microsoft documents limits on sparklines per visual and points per sparkline; aggregate the X-axis to month or week for long ranges.
- Independent scales: a flat-looking line can still be a large absolute change.
- Sparklines don't export to Excel; the underlying numbers do.
- Sorting the table by the sparkline column is not possible; sort by the measure next to it.
FAQ
Can I colour the sparkline by performance?
The sparkline colour is set per sparkline, not by rule. Put a conditional-formatted icon or value next to it to show good or bad.
Do I need an SVG measure instead?
Only for styles the native sparkline doesn't offer (target bands, area with gradient). The SVG measure builder covers those.
Sources
- Microsoft Learn: Create sparklines in a table or matrix
- Microsoft Learn: Sort one column by another column
Menu names follow Power BI Desktop as documented on Microsoft Learn; they can move between releases. The companies and figures in the worked example are invented.
Related
Assets and guides that go with this technique.
More Power BI techniques
- Custom Conditional Formatting Icons
- Dynamic Titles
- Power BI Field Parameters: Switch Measures and Axes
- Calculation Groups
- Toggle Between a Chart and a Table with Bookmarks
- Drillthrough to a Detail Page
- Report Page Tooltips
- Small Multiples
- Top N with 'Others'
- Sort Month Names Correctly
- Colour Bars and Cells by a Measure