Horizontal Bar Sparklines
Horizontal bar sparklines, also called hbar sparklines, are small bar charts that display data as horizontal bars. They are used to compare values across categories in a compact, space-efficient format.
When to use horizontal bar sparklines
- Comparing multiple categories: Compare values such as sales, expenses, or performance across categories or time periods.
- Tracking trends or rankings: Show which categories are performing well and which are underperforming along a horizontal axis.
- Spotting variations: Make it easier to detect patterns, fluctuations, or outliers in category-based data.
Create a horizontal bar sparkline
- On the Insert tab, select Sparklines.
- Under Bar Sparkline, select Insert Hbar Sparkline. The HbarSparkline Setting dialog opens.
- Enter a number or reference that defines the length of the bar, such as
0.3orA1. - Select the color scheme. The default is gray.
- Click Ok. The sparkline is inserted into the selected cell.
Edit a horizontal bar sparkline
- Select the horizontal bar sparkline in your workbook.
- On the Sparkline tab, select Settings. The HbarSparkline Setting dialog opens.
- Set the parameters, then click Ok.
- Copy and paste the sparkline cell to duplicate the configuration in another location, as needed.
Horizontal bar sparkline parameters
The horizontal bar sparkline formula supports the following format:
=HBARSPARKLINE(value, colorScheme, axisVisible, barHeight)
| Parameter | Description |
|---|---|
| Value | Specify the length of the bar, such as 0.3 or A1.
|
| ColorScheme | Set the color of the bar. Default: gray. |
| axisVisible | (Optional) Show or hide the axis. Default: true. |
| barHeight | (Optional) Set the bar height as a percentage of the cell height (greater than 0 and less than or equal to 1). |
| LET function | (Optional) Define bar color based on value using the LET function with IF conditions. |
Example – Bar color based on performance
To dynamically change the bar color based on performance levels, assign a different color to each threshold. In this example, the value in B7 represents a performance score between 0 and 1. Higher scores receive darker, stronger colors, while lower scores shift toward lighter or warning colors. The formula below:
- Stores the performance value in a variable (
ref) - Determines the appropriate color based on defined thresholds
- Generates a horizontal bar sparkline using that color
=LET(ref,B7,color,IF(ref>=0.8,"#092834",IF(ref>=0.6,"#347B98",IF(ref>0.4,"#66B032",IF(ref>=0.2,"#B2D732",IF(ref>=0,"#F0F7D4","red"))))),HBARSPARKLINE(ref,color))