Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

barritown

Applying Decluttering Best Practices in Power BI | Line Chart with Labelled Lines instead of Legend

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?

 

screen_1.png

 

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.

 

screen_2.png

 

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.

 

screen_3.png

 

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.

 

screen_4.png

 

After that you can just switch off the legend and enjoy the result.

 

screen_5.png

 

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)

My YouTube vlog in English

My YouTube vlog in Russian