Forum Discussion

ThomasSan's avatar
ThomasSan
Helper IV
3 years ago
Solved

Conditional formatting is not displaying 0 correctly

Hi everyone,

 

I am trying to introduce conditional formatting for my percentage value in order to better show whether our various sales figures have increase or decreased. In order to do that, I would like to keep the + sign before the percentage value. See the example below:

As you can see, the percentage value of International Sales and All Sales are behaving as intendend i.e. - sign to show that International Sales have decreased by 18%, + sign to show that All Sales have increased by 6%. However, when sales remain flat, I am unable to have only a 0 shown in front of my percentage value as can be seen above.

 

I have my percentage measure formatted as follows:


The dax for my measure does not contain any further formatting code:

CM %delta Our Sales = 

var cyOurSales=
[CM CY Sales]

var pyOurSales=
[CM PY Sales]

var div=
SWITCH(
    TRUE(),
    ISBLANK(cyOurSales)&&ISBLANK(pyOurSales),
    BLANK(),
    cyOurSales = 0,
    -1,
    DIVIDE(
        cyOurSales,
        pyOurSales,
        BLANK()
    ) -1
)

return div

 

Does anyone know why PowerBI is not working as expected. What can I do in order to have the measure format the values as desired i.e. +5%, 0%, -5%?

  • Hi ,  ThomasSan 

    According to your description, you use the "+#%;-#%;0%" in the format of the measure , but it returns the "+%" in your visual , and you want to show the "0%" for it .

    I test it  in my side , it may be caused by the measure value is very small but it is a  positive number,like this:

    This is the "+#%;-#%;0%" judgement just have three conditions: Positive number, negative number and 0.

    If you want to when the measure return value is very small you can add a logic in your measure to return 0:

    Measure = IF(ABS( SUM('Table'[Column1]) ) < 0.01 ,0 , SUM('Table'[Column1]))
     
    Then we can get the value like this in the visual:

     

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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

     

2 Replies

  • Hi ,  ThomasSan 

    According to your description, you use the "+#%;-#%;0%" in the format of the measure , but it returns the "+%" in your visual , and you want to show the "0%" for it .

    I test it  in my side , it may be caused by the measure value is very small but it is a  positive number,like this:

    This is the "+#%;-#%;0%" judgement just have three conditions: Positive number, negative number and 0.

    If you want to when the measure return value is very small you can add a logic in your measure to return 0:

    Measure = IF(ABS( SUM('Table'[Column1]) ) < 0.01 ,0 , SUM('Table'[Column1]))
     
    Then we can get the value like this in the visual:

     

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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

     

    • ThomasSan's avatar
      ThomasSan
      Helper IV

      Hi! Yes, the problem appears for digits that are being rounded down. It is baffeling to me that when a value is being rounded down to a 0 value, the displayed value is not picking up the formatting for a 0 value.

       

      However, your solution was helpful in displaying 0 values as desired! Thanks you