Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Switch colour card filter by field value

I'm formating a card by FIELD VALUE

 

Is there a way to get this switch formula to turn greater than 0 green e.g. "#094" and red if less than 0 e.g. "#d64550";

 

My current code is:

Measure Value Color = SWITCH(TRUE(),
[% Average 2019] >0,"#D64550",
[%Average 2019] =0,"#252423",
[% Average 2019] <0,"#094",
[% Average 2020] >0,"#D64550",
[% Average 2020] =0,"#252423",
[% Average 2020] <0,"#094"
)
 
It keeps turning red for some reason when it's +18.54%
Attendance average.PNG
Thanks
2 REPLIES 2
daxer-almighty
Solution Sage
Solution Sage

You can't have one measure that will return different values for the average in 2019 and 2020. Only the first true condition will be honored. So, you see 18.54% being red because this color comes from the other measure. In all honesty, in your color measure none of the 3 last conditions will ever be hit since the first 3 already cover all possibilities. Use 2 different color measures for the 2 different numerical measures. By the way, in the measures given by @nandukrishnavs you don't have to multiply by 100 since you're only comparing to 0.

nandukrishnavs
Super User
Super User

@Anonymous 

 

Try to write two measures.

 

Color2019 =
VAR _val = [% Average 2019]*100
VAR _result =
    SWITCH (
        TRUE (),
        _val > 0, "#D64550",
        _val = 0, "#252423",
        _val < 0, "#094"
    )
RETURN
    _result
Color2020 =
VAR _val = [% Average 2020] * 100
VAR _result =
    SWITCH (
        TRUE (),
        _val > 0, "#D64550",
        _val = 0, "#252423",
        _val < 0, "#094"
    )
RETURN
    _result

 

If your format of measure ([% Average 2020], [% Average 2019) is not the percentage, then you don't need to multiply 100.

 




Regards,
Nandu Krishna

Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 👍

Proud to be a Super User!


Regards,
Nandu Krishna

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.