Search code examples
chartspowerbidaxvisualizationpowerbi-desktop

Line chart: Current month should be dynamically displayed in different colors


My challenge:

I have a line chart in Power-BI.

This shows the running sum auf my working hours per day of the month (see below).

Today I am changing the recent month (here: September) in a different color like the past months.

I want that the line for the recent month is colored dynamically different.

enter image description here

What I have tried:

Solution 1:

  • Create two measure: one for the effort of the recent month and another one for non-recent month

  • Recent Month

     Laufende Summe von Taetigkeit_Dauer_t - recent month = If(
     [Leistungsdatum_Monat Measure] = MONTH(Today()),
     0,
     [Laufende Summe von Taetigkeit_Dauer_t in Tag])
    
  • Past Month

     Laufende Summe von Taetigkeit_Dauer_t - past month = If(
     [Leistungsdatum_Monat Measure] = MONTH(Today()),
     0,
     [Laufende Summe von Taetigkeit_Dauer_t in Tag])
    
  • Tried to make a line chart and drop the measures on the y-axis and the seconday y-axis, but it was not allowed.

Solution 2:

Examplefile:

https://www.swisstransfer.com/d/db51ea00-1d8d-4d54-b2c5-bf9735c7fb4a

Thank in advance!


Solution

  • This is an excellent chart but what you want to do is not currently possible with native Power BI visuals. The problem you have is that you have a single measure which gives you a single line series. You are then getting further month granularity by then adding a legend. Once you're at this stage, you can only select static colours from the formatting pane. The alternative is to have a measure for each month line but this is then not dynamic when your data updates. The normal way to do this is to convert the line to a bar chart (ensure no legend), use the bar chart conditional formatting and then convert back to a line chart where the conditional formatting still works in the background but again this only works if you already have the granularity (which you do not).

    The chart is a great way of visualising data but would only currently be possible in something like Deneb.