Share via

Quick measure Power BI

Rene Calderon 20 Reputation points
2026-03-04T19:29:04.4933333+00:00

I'm trying to add an if statement to the quick measure to basically say if the percentage is negative the text should be in red with the negative sign in front, and if its positive the number should be in green with the plus sign in front. but I keep getting an error message.

Screenshot 2026-03-04 112524

Microsoft 365 and Office | Other

3 answers

Sort by: Most helpful
  1. Rene Calderon 20 Reputation points
    2026-03-05T00:42:25.1866667+00:00

    thank you, but I'am not getting the desire resultScreenshot 2026-03-04 164007

    0 comments No comments

  2. Gérard Oomens 121.3K Reputation points Volunteer Moderator
    2026-03-04T21:30:13.79+00:00
    0 comments No comments

  3. Q&A Assist
    2026-03-04T19:29:19.5+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Use the quick measure as the numeric base, then create a separate DAX measure (or visual calculation) that returns formatted text and apply conditional formatting from it.

    Assume the quick measure is:

    Parts % Diff = 
    VAR __BASELINE_VALUE    = SUM('Parts'[2024 ACTUAL])
    VAR __VALUE_TO_COMPARE  = SUM('Parts'[2025 ACTUAL])
    RETURN
        DIVIDE(__VALUE_TO_COMPARE - __BASELINE_VALUE, __BASELINE_VALUE)
    

    Create a new measure for the signed, color-driving value:

    Parts % Diff Display = 
    VAR v = [Parts % Diff]
    RETURN
        IF(
            v < 0,
            "-" & FORMAT( ABS(v), "0.00%" ),
            "+" & FORMAT( v, "0.00%" )
        )
    

    Then:

    1. Put Parts % Diff in the visual as the value (so it stays numeric).
    2. Use Parts % Diff Display only for conditional formatting:
      • For a table/matrix, open Conditional formatting for the Parts % Diff field.
      • Choose Format by: Rules or Field value and select the display (or another helper) measure.
      • Set rules such as < 0 = red, >= 0 = green. When working with percentages, enter rule values as decimals (for example, 0 and 0.25) and choose Number as the format, not Percent.

    If using visual calculations (preview), the same logic can be written as a visual calculation and then used as a hex color field for conditional formatting, similar to:

    Parts % Diff Color = 
    IF( [Parts % Diff] < 0, "#E91C1C", "#5BA300" )
    

    Set its data type to Text, hide it from the visual, and select it in the conditional formatting dialog.


    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.