Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

power bi gauge conditional formatting

Hi,

 

I hope you can assist me.

I have a gauge graph with two numbers that change every month, I want to do conditional formatting that if the first number is bigger by the second, the color of the graph will be green and if other, it will be red.

Do you have any idea how to do it?

 

Thank you,

 

 

 

 

 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    You might consider creating a conditional format for each measure in the matrix, like this.

    Measure 1 = 
    VAR _cur_month_value = [@Sales]
    VAR _pre_month_value = CALCULATE([@Sales],DATEADD('Calendar'[Date],-1,MONTH))
    VAR _color = IF(_cur_month_value>=_pre_month_value,"Green","Red")
    RETURN
    _color
    Measure 2 = 
    VAR _cur_month_value = [@Profit]
    VAR _pre_month_value = CALCULATE([@Profit],DATEADD('Calendar'[Date],-1,MONTH))
    VAR _color = IF(_cur_month_value>=_pre_month_value,"Green","Red")
    RETURN
    _color

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    You might consider creating a conditional format for each measure in the matrix, like this.

    Measure 1 = 
    VAR _cur_month_value = [@Sales]
    VAR _pre_month_value = CALCULATE([@Sales],DATEADD('Calendar'[Date],-1,MONTH))
    VAR _color = IF(_cur_month_value>=_pre_month_value,"Green","Red")
    RETURN
    _color
    Measure 2 = 
    VAR _cur_month_value = [@Profit]
    VAR _pre_month_value = CALCULATE([@Profit],DATEADD('Calendar'[Date],-1,MONTH))
    VAR _color = IF(_cur_month_value>=_pre_month_value,"Green","Red")
    RETURN
    _color

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you! it worked!