How to add an horizontal line to a Power BI chart?

Here’s a question from Alice:

I am working on a dashboard which includes a stacked bar chart. Need to add a constant line that runs horizontally starting the ;eft hand side of the y axis and is based on a measure in the data model. Any ideas on how to proceed?

Step 1: Create your Power BI chart

  • At the bottom of the Power BI Report View hit the + icon to add a new Page to your report.
  • From the Visualizations pane, drag a new visual. In this example we will use a Stacked column chart.
  • Drag the relevant fields into your chart. In this example we will use the Month name field for the X axis. the Amount Sum for the Y-Axis and the Course Name for the legend.

Step 2: Insert a constant horizontal line

To add an horizontal reference line parallel to the X – Axis, proceed as following:

  • Select your visual.
  • From the Visualizations pane, hit the magnifying glass (add analyses to your visual).
  • Under Constant Line. hit the Add Line link.
  • Name your horizontal line – in this case the selected name will be Profitability.
  • Type a Value – in our case, we selected 13000.
  • Set the Line style and Position.

Here’s the chart

Here’s our chart – note the dashed line running in parallel to the x-Axis line.

Note: Make sure to adjust the Transparency setting in case that your constant line is not showing up.

Step 3: Insert an horizontal line based on measure

Another option is to base the reference line on the value of a measure:

  • First, off let’s define a measure in our data model. In our case we’ll define a measure representing the Average Sales Amount.
  • We will then hit the Add further Analyses to your visual button.
  • Under Value, hit the function button.
  • Pick the Measure from the data model.
  • Hit OK.
  • The horizontal line data label and position values will be updated as shown below:

Next Learning

How to count table rows meeting a specific condition in Power BI?