Forum Discussion

klehar's avatar
klehar
Helper V
4 years ago
Solved

Conditional Formatting a Line Chart in Power BI

I'm not sure if this is possible in Power BI, but want to try workarounds

 

My requirement:

For my data given below, I want to color Actuals with a different color and my Non Actuals with a differnt color on a line chart.

DateValueType
1/1/2021100Actuals
1/2/2021200Actuals
1/3/2021300Actuals
1/4/2021400Actuals
1/5/2021500Actuals
1/6/2021640Forecast 1
  • You can use two measures instead of conditional formatting: one measure for Actuals and the other for the Forecast values (this measure must include the actual values to avoid the blank space in the chart). so:

    Actuals = SUM(Table [Actuals]
    Forecast = SUM(Table [Forecast]) + [Actuals]

     

    Place both measures in the values bucket and then format each measure to your liking:

     

7 Replies

    • PaulDBrown's avatar
      PaulDBrown
      Community Champion

      Here are two options:

      1) Since the default line chart doesn' allow conditional formatting, you can hack it by creating a bar chart first, adding the conditional formatting and then changing it to a line chart.

      I've created this measure to format the chart:

       

      Line Colour = IF(MAX('Table'[Filter/Type]) = "Actuals", 1, 2)

       

       2) Use two measures for the line chart. The measure you already have for the forecast and another for "Actuals"

       

      Actuals = CALCULATE([Sum Value],'Table'[Filter/Type] = "Actuals")

       

      Add both measures to the Values bucket and then format each meaure to your liking:

       

      • klehar's avatar
        klehar
        Helper V

        Pragati11 PaulP 
        While your bar chart solution is quite intuitive, I'm using first the traditional line chart solution

        However I get a gap and want the lines to be joined on my actual dataset.

        If this doesn't work I'll like to try the bar chart approach.

        However what measure should i use in the bar chart in the value column, since conditional formatting requires me to have only 1 value.

        PaulDBrown 

         

         

  • Hi klehar ,

     

    Is this what you are looking for?

    There are only categories under Type column: Actuals and Forecast1

    I have moved them to the LEGEND section of the line chart visual.

    Forecast1 just has one row in your sample data therefore it is shown as a dot.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Pragati11 sorry to biggie back on this but it kinda aligns.

       

      I have a date axis, 1 line in my line graph and able to see forecast in my analytics.  However it displays pff and is greyed out.  Any logic to this? 

       

      • Pragati11's avatar
        Pragati11
        Super User

        Hi Anonymous ,

         

         Not sure if this is the right thread for you to post your question as i is not related to the question of the original thread.

        Can you please create a new thread for your question? In this way you are not taking over other person's thread.