Power BI Scatter Chart Ratio Line
Adding context to the Power BI scatter chart to help make your visuals tell the story of the data.
The Scatter Chart in Power BI has various analytical features that can be added to the visual.
The main drawback in using them is that the report creator, and report user isn’t able to see the values produced by them nor the statistical calculations that are being used in the backend to create the output.
This can cause an issue if questions arise when the report user may question the validity of the statistical analysis being done on a visual. So in order to ensure that we avoid any awkward conversations relating to any given statistical analysis provided, we need to ensure that we fully understand and provide the report user with the requisite information relating to any analysis provided along with the visual created.
One such example of this is the scatter plot’s ratio line.
Let’s take for example the very simple dataset as is shown below.
In a Power BI scatter plot the chart looks like this:
Our visual could definitely use some sprucing up, let’s provide the report users with a bit of context by showing which values are above or below the average.
In the Scatter Chart Analytics menu, and add a ratio line.
The Ratio Line is shown as follows.
Now let’s define a ratio line
The ratio line is a straight line that starts from the origin (0,0) and extends outwards. Its slope is determined by the overall relationship between the total sum of values on the Y-axis and the total sum of values on the X-axis for all the data points displayed in the scatter plot.
Essentially, it visually represents the average ratio of the Y-axis measure to the X-axis measure across all plotted categories.
As stated earlier, this is all well and good but how do we check that Power BI has calculated this right and how can we show these values in a visual (table etc) if it’s requested? The last thing we want is to be quizzed about “that line in the scatter plot” in a meeting and we can’t accurately provide an answer (because that’d be awkward, wouldn’t it?).
Even if it’s not a requirement of the report it’s still a good idea to check that the calculation is being done correctly in Power BI; doing this also gives you confidence in knowing more about the Ratio Line, rather than just blindly adding to your chart.
This will also allow us to include the ratio line values in our tooltip and even provide above/below values to the tooltip also so the report user can tell exactly how close to the average each data point is.
Let’s now cut to a nice little snippet generated by my good friend Gemini to describe how we calculate the line.
Showing the calculations in Power BI
For this we need some basic DAX, a sum of each column (X and Y) and a basic calculate statement to give us the total of each column ignoring the row context of each category.
From this we can work out our Ratio amount and then the ratio value for each category, followed by the variance of each category value to the ratio line.
Sum X = SUM ( Data[X] )
Sum Y = SUM ( Data[Y] )
Sum X ALL = CALCULATE ( [Sum X], ALL ( Data[Category] ) )
Sum Y ALL = CALCULATE ( [Sum Y], ALL ( Data[Category] ) )
Ratio = DIVIDE ( [Sum Y ALL], [Sum X ALL] )
Ratio Line X Position = [Sum X] * [Ratio]
Above or Below Ratio = [Sum Y] - [Ratio Line X Position]
Above or Below Ratio Colour = IF ( [Above or Below Ratio] > 0, "#118DFF", "#000000" )
Let’s put this all together in a visual and add the values in a card and table for context. Also, let’s highlight when a data point is above average to make it visually obvious.
And there we have it! Looking pretty good I’d say.
If you’d like to check the finished product in a pbix file, see my Github here:
Y Axis Ratio.pbix, the finished file github.com/InsightfulAnalytics/PBI-Files
If you would rather read about colour than analytics lines, the piece on storing hex codes in measures covers the trick used above to turn the above and below points different colours.
This article was first published on my Substack in May 2025. I no longer post there, so it lives here now.
Need the numbers behind the visual?
Analytics lines are the easy half. If the model underneath them needs work, that is what I do for a living.