Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

How to add color code whenever exception comes down in line graph

Hello Experts ,

 

How to add color code whenever exception comes down in line graph ?here in below screenshot whenver line comes down or to low line should be red color .Please advise me how to do ?any expression or dax query for this please share me it will be helpfull for me 

 

  • Hi sabih786,

    As I know, we  can't set conditional format for data colors when we have legend. so one workaround is that you could try to add id in filter, and use clustered column chart at first

     

    Total Sales = SUM(chart[amount])
    % Change = 
    VAR CurrentSales = [Total Sales]
    VAR CurrentMonth = MIN(chart[year])
    VAR PreviousSales = 
    CALCULATE(
        [Total Sales],
        FILTER(
            ALLSELECTED(chart),
           chart[year] = CurrentMonth - 1
        )
    )
    RETURN
    DIVIDE((CurrentSales - PreviousSales),PreviousSales)
    

    Then switch chart to line chart, you will get result like below

     

    You could refer to Power BI - Line Markers with Conditional Formatting for details.

    Best Regards,
    Zoe Zhi

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

1 Reply

  • dax's avatar
    dax
    Icon for Community Support rankCommunity Support

    Hi sabih786,

    As I know, we  can't set conditional format for data colors when we have legend. so one workaround is that you could try to add id in filter, and use clustered column chart at first

     

    Total Sales = SUM(chart[amount])
    % Change = 
    VAR CurrentSales = [Total Sales]
    VAR CurrentMonth = MIN(chart[year])
    VAR PreviousSales = 
    CALCULATE(
        [Total Sales],
        FILTER(
            ALLSELECTED(chart),
           chart[year] = CurrentMonth - 1
        )
    )
    RETURN
    DIVIDE((CurrentSales - PreviousSales),PreviousSales)
    

    Then switch chart to line chart, you will get result like below

     

    You could refer to Power BI - Line Markers with Conditional Formatting for details.

    Best Regards,
    Zoe Zhi

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.