January 19, 2022

How to Create Sparklines in Power BI

By Connor Burton

Two of the most commonly used visualizations in Power BI became a lot more versatile. The December 2021 update of Power BI Desktop includes an exciting new feature, sparklines. 

In this post, we will discuss what sparklines are and how they can be used to give your tables and matrices a boost with additional context and insights — all in just a few clicks.

What is a Sparkline in Power BI?

A sparkline is a kind of trend chart that is generally shown as a bar or line graph to give additional context to a KPI or metric. Sparklines don’t have axes or data labels as they tend to be smaller charts meant for the purpose of conveying a trend in the data. They are usually paired with another visual or metric and are not generally shown as a stand-alone visual. In Power BI, sparklines are currently enabled to be used with the table and matrix visualizations.

How to Enable Sparklines in Power BI Desktop

In order to add sparklines to your Power BI visuals, you need to make sure that the feature is enabled in your version of Power BI desktop (since it is a preview feature currently). In your Power BI Desktop file, click the File tab in the top left corner. After clicking that, select Options and settings, then Options. An Options window will appear; click Preview features under the GLOBAL section and make sure sparklines has a checkmark next to it. Click OK. You are now able to use sparklines in your Power BI reports.

If the sparklines option is not available, it is likely that you don’t have the December 2021 version of Power BI Desktop. You can download the latest version of Power BI Desktop here.

A screenshot showing the options section of Power BI to enable Sparklines

How to Add Sparklines in a Table or Matrix Visualization

In this example, we will walk you through the steps to add sparklines to the table below. This will give us the ability to look at the overall trend of sales for each category. There are two ways to add a sparkline to your visualization. The option we are using in this example is the one we prefer, but we have also added the alternative option into the Alternative Option to Add a Sparkline section at the end of this post.

A table showing an example of overall trend of sales for each category

Make sure you are selected on your table visualization. In the Values section of the Visualizations pane, click the dropdown arrow of the field that you want to add the sparkline to (Sales in this example), and then click Add a sparkline. Something to note here is that sparklines are only available for numeric data fields.

A screenshot of the values section of the visualization pane in Power BI to navigate adding a sparkline
A screenshot showing how to add a sparkline

After clicking Add a sparkline, the window below will pop up. Fill in the necessary fields, and click Create.

  • Y-axis: Sales will populate this by default since we clicked on that to add the sparkline.
  • Summarization: In our table, we are looking at the sum of sales for each category, so Sum will appear as the default Summarization here.
    • Other Summarization options include, but are not limited to, average, minimum, maximum, and count.
  • X-axis: This is the field that your data is trending over – this will often be some type of date. For this example, we will use the Order Date.
A screenshot showing a pop-up window to create a sparkline in Power BI
A screenshot of a window to add a sparkline on the x-axis

After clicking Create, the sparklines will appear in your table visualization. The sparklines in our example are showing the trend of sales for each category from the earliest Order Date to the latest Order Date. This will also add a new field to the Values section of the Visualizations pane.

A screenshot of the sparklines in the table visualization
A window showing a sales by order date selection

There are two important things to understand when selecting your field for the X-axis:

1. Sparklines allow for a maximum of 52 data points on the X-axis. If the field selected to be on the X-axis exceeds 52 data points (more than 52 Order Dates in our example), there will be a small information icon directly above the table that will display a message when you hover over it (see image below). This means that the sparkline will still show the overall trend of the data, but it won’t have every single data point from the field on the X-axis.

A screenshot of a Power BI table error message for too many datapoints

2. Make sure to be cautious when using a date hierarchy on the X-axis of your sparklines, especially if there are multiple years in your date field. If you select Month in the dropdown below, then the sparklines will represent the summation of Sales across each month in the data regardless of the year. For example, all of the sales data in the month of January would be grouped into one datapoint on the sparkline; this would happen with each of the twelve months. The sparkline would be more of a way to look at each month’s Sales over a multiple-year span.

A screenshot of the X-Axis window in Power BI highlighting the date hierarchy selections

Editing an Existing Sparkline

If you want to edit an existing sparkline (i.e. change the summation, change the field on the X-axis or Y-axis), click the dropdown arrow for the sparkline in the Values section of the Visualizations pane. Then click Edit sparkline.

A screenshot showing the navigation of the dropdown arrow for the sparkling in the values section of the Visualizations pane
A screenshot of the edit sparkline drop-down selection in Power BI

This will open up an Edit sparkline window where you can make changes to the Y-axis, Summarization, or X-axis. After making changes, click OK.

A screenshot of the edit sparklines pane in Power BI

Formatting Sparklines in Power BI

Make sure you are selected on your table visualization with the sparklines. In the Visualizations pane, click the Format your visual button.

A screenshot of navigating the format your visual in the visualizations pane

After clicking that button, select Sparklines.

A screenshot of the visualizations format visual controls with the sparklines control outlined

After selecting Sparklines, you will have the option to change the chart type, data color, width of the line, and marker.

a screenshot of sparkline visual options to change the data color, chart type and width
  • Chart type: sparklines can be a line chart (first image below) or a column chart (second image)
A screenshot of the sparklines in the table visualization
The sparklines in the sales visualization example as a column chart
  • Data color: The color can be changed to whichever color you prefer. Currently, there is no option for conditional formatting of sparkline colors.
  • Width: You can adjust the thickness of the sparkline. This option is only available if the sparkline is a line chart. 
  • Marker: You can add a marker to the sparkline to call out specific points of data. This option is only available if the sparkline is a line chart. Multiple markers can be added to the sparklines, like if you wanted to see the highest and lowest points for each Category (example below). Once a marker is added, you can change the color, type, and size of the marker. 
A screenshot of adding markers to sparklines
A screenshot of the visualization example showing sparklines with markers

Power BI Sparklines Pro Tips

  • Sparklines can only be used in table and matrix visualizations.
  • If you hover over the sparkline in the visualization, a tooltip will appear showing the minimum and maximum of the data points.
  • As noted above, sparklines allow for a maximum of 52 data points.
  • The maximum number of sparklines that can be in visualization is five, meaning you can have five different columns with sparklines.
  • The maximum number of columns in a matrix visualization with sparklines is 20.

Alternative Option to Add a Sparkline

Make sure that you are selected on your table or matrix visualization. In the Insert tab of the Power BI Desktop ribbon, click Add a sparkline.

A screenshot of a Power BI navigation bar under the "insert" tab showing where the "add a sparkline" button is located

An Add a sparkline window will pop up. You will need to fill in each of the sections in the window, and then click Create.

A screenshot of the "add a sparkline" window in Power BI

Conclusion

Sparklines are a new feature in Power BI that gives users the ability to add useful insights and context to their table and matrix visualizations. It is now possible to have a table visualization and be able to see trends in the data without creating two separate visualizations. This tool will be extremely useful when building reports!

Interested in learning more about the data visualization tools in Power BI? Reach out to phData’s team of Power BI experts today to have all your questions answered!

FAQs

Using a sparkline is a good idea when you want to show general trends in the data over time. If you need to show more specific details in the data, then it would be better to create a separate visualization.

A sparkline is basically a condensed version of a line chart or column chart. Sparklines will not have titles, axes, or data labels while a line chart or column chart generally will. Line charts and column charts as standalone visualizations can provide more details than a sparkline.

Data Coach is our premium analytics training program with one-on-one coaching from renowned experts.

Accelerate and automate your data projects with the phData Toolkit