web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Colour fx

(0) ShareShare
ReportReport
Posted on by

I am fairly new to Power BI / DAX and trying to write an expression that will change the colour of the variables '_variance' and '_variance_year' in a Power BI card. The measure that I have created for the text in the Card Callout value is:

Previous Term | Previous Year =
VAR _variance = DIVIDE([ReleasedOnTime], [Previous Term]) -1
VAR _variance_year = DIVIDE([ReleasedOnTime], [PreviousYear]) -1
RETURN
FORMAT(_variance, "#%") & " " & IF(_variance >= 0, "▲", "▼") & " | " & FORMAT(_variance_year, "#%") & " " & IF(_variance_year >= 0, "▲", "▼")
 
I would like the colour of each variable to change depending on whether the value is positive or negative: Green for positive, red for negative. I have tried to use the code below in the colour fx but it changes both variables to the same colour, based on the _variance value. The two lines that I have made bold don't seem to be working correctly. Can anyone help?

ColourCard =
VAR _variance = DIVIDE([ReleasedOnTime], [Previous Term]) - 1
VAR _variance_year = DIVIDE([ReleasedOnTime], [PreviousYear]) - 1
RETURN
    SWITCH(
        TRUE(),
        _variance >= 0 && _variance_year >= 0, "Green", -- Green color for both positive
        _variance >= 0 && _variance_year < 0, "Green", -- Green color for _variance, red for _variance_year
        _variance < 0 && _variance_year >= 0, "Red", -- Red color for _variance, green for _variance_year
        _variance < 0 && _variance_year < 0, "Red" -- Red color for both negative
    )

Categories:
I have the same question (0)
  • Mitanshu Profile Picture
    1,658 Moderator on at

    To achieve different colors for the _variance and _variance_year values in a Power BI card, you will need to use two separate measures for coloring each part.

    1 - Create Measures for Formatted Text:

    Formatted Variance Text =
    VAR _variance = DIVIDE([ReleasedOnTime], [Previous Term]) - 1
    VAR _variance_year = DIVIDE([ReleasedOnTime], [PreviousYear]) - 1
    RETURN
    FORMAT(_variance, "0.0%") & " " & IF(_variance >= 0, "▲", "▼") & " | " &
    FORMAT(_variance_year, "0.0%") & " " & IF(_variance_year >= 0, "▲", "▼")


    2 - Create separate measures to determine the color for each value:

    Variance Color =
    VAR _variance = DIVIDE([ReleasedOnTime], [Previous Term]) - 1
    RETURN
    IF(_variance >= 0, "Green", "Red")

     

    Variance Year Color =
    VAR _variance_year = DIVIDE([ReleasedOnTime], [PreviousYear]) - 1
    RETURN
    IF(_variance_year >= 0, "Green", "Red")


    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If this post or my previous reply was useful in other ways, please consider giving it Thumbs Up.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 429 Most Valuable Professional

#2
11manish Profile Picture

11manish 191 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 122 Super User 2026 Season 2

Last 30 days Overall leaderboard