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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
After clicking that button, select Sparklines.
After selecting Sparklines, you will have the option to change the chart type, data color, width of the line, and marker.
- Chart type: sparklines can be a line chart (first image below) or a column chart (second image)
- 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.
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.
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.
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!
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.