March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
DataViz experts from all around the world propose a lot of techniques and best practices to make your visuals more simple and yet more appealing. Some of those techniques and best practices are just a couple of clicks away when you are eager to apply them in Power BI, but some of them require a little bit more efforts, hence clicks.
In this blog entry, I will share with you a decluttering technique for a line chart which belongs to the latter category and allows you to get rid of the legend on your Line Chart visual and replace it with labels assigned to lines.
Intrigued? Keep reading then!
If you prefer consuming visual materials to reading, don't hesitate to find pretty much the same content in the form of shorts on my YouTube channels.
Here they are - in English and in Russian.
Enough for the intro, let's commence.
Assume you have such a simple dashboard and you are asked a simple question - which currency, AUD (Australian Dollar) or BRL (Brazilian Real), is valued higher?
Now, describe your actions to answer it.
Don't you mind I will do it for you?
Here they are:
1) You check the legend and find the colours related to AUD and BRL.
2) Then you find those colours on the chart.
3) Then you give yourself a couple of moments to define which line is higher and provide the right answer - AUD.
Will you agree with me that using the slightly modified chart below you would have answered the same question in the blink of an eye? I am pretty sure you will.
So how do we apply this technique in Power BI?
First of all, we compose such a measure:
Caption =
/* locating the last date with data on the visual */
VAR maxDate = MAXX ( ALLSELECTED ( CBRrates ), [data] )
/* forming text for the label */
VAR currentCurrency = SELECTEDVALUE ( CBRrates[cdx] )
/* showing this text only for the latest date with data */
RETURN IF ( SELECTEDVALUE ('Date'[Date] ) = maxDate, currentCurrency, BLANK() )
Then we activate data labels in the Line Chart settings, replace the standard values with our measure and format them as we like.
After that you can just switch off the legend and enjoy the result.
Hope you will find this blog entry useful and applicable for some of your dashboards.
Kudos, comments and even constructive critics are welcomed.
Cheers,
Alexander (aka @barritown)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.