Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I have a conditional formatting based on a measure that basically indicates the variartion respect last month value.
It works perfectly well except when this measure is exaclty 0 (no variation respect last month), then instead of showing yellow it shows black. Is this a bug?
The measure is basically a switch
SWITCH (
TRUE,
measure > 0, "green",
measure < 0, "red",
measure = 0, "yellow",
BLANK ()
)
Thanks
Hi, @Claudioffj
It might have something to do with the way Power BI interprets measures or formatting rules. Here are a few steps to troubleshoot and resolve the issue:
Ensure that the measure calculations with a value of 0 are accurate. Sometimes, even subtle differences in calculations can cause conditional formatting to behave unexpectedly. Double-check that the measure actually returns 0 and not a very small number close to 0 or .
Although your utterances look correct, it's worth reviewing the conditional formatting rules in the Power BI interface to make sure they're logically consistent with the utterance. For a detailed guide to setting up conditional formatting, see the official documentation here:
Apply conditional table formatting in Power BI - Power BI | Microsoft Learn
Make sure that the data type of the measure and its aggregation status, if any, are compatible with the conditional formatting rules. The incompatibilities here can sometimes lead to unexpected formatting results.
If the problem persists after following these steps, it may be helpful to explore alternatives to the implementation logic, such as using calculated columns or different DAX functions that may handle 0 values more explicitly in the context of conditional formatting.
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Yes, the result is indeed 0. If the value for the current month and the previous month is 0, the conditional formatting does not work.
My variation measure is a simple calculation of current month - previous month.
The results are as follows:
Current Month = 10 - Previous Month = 5 = 5 => formatting OK
Current Month = 0 - Previous Month = 5 = -5 => formatting OK
Current Month = 0 - Previous Month = 0 = 0 => formatting does not work
I've just created a simple 'Enter Data' model with 3 rows: -1, 0, 1. I've placed them in a table and used a measure:
Measure Colour = var measureVal = SUM(Example[Measure])
var output = SWITCH (
TRUE,
measureVal > 0, "green",
measureVal < 0, "red",
measureVal = 0, "yellow",
BLANK ()
)
RETURN
output
I've then put those values in a table and got this result:
I can only summize there is some other element at play here that is not found in your description.
User | Count |
---|---|
102 | |
88 | |
78 | |
71 | |
69 |
User | Count |
---|---|
113 | |
99 | |
97 | |
72 | |
68 |