cancel
Showing results for
Did you mean:
Frequent Visitor

## Color fill based on value in a number field.

I have a data card with a numerical field. I want to color fill this field based on the numeric value of the field (a sum of other combined fields). For example if the field ends up with a value of less than or equal to 10 I want it to fill red, if greater than 10 but less than 15 , yellow, above 15 green.

Here is what I am trying:

If

(Value(DataCardValue418.Text)<= 10, Color.Red,Color.White ||
Value(DataCardValue418.Text) >10 && Value(DataCardValue418.Text)<= 15, Color.Red,Color.White ||
Value(DataCardValue418.Text)> 15, Color.Red, Color.White

)

I get a red underline underneith the "White" with an explaination "Invalid Arguement type. Expecting one of the following: Boolean, Number, Text, OptionSetValue, UntypedOblect".

If I try ;

If(Value(DataCardValue418.Text)<= 10, Color.Red,Color.White)

by itself it works. So I must be missing something simple around the Or's ??

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Resolver II

Try this:

If(Value(DataCardValue418.Text)<= 10, Color.Red,
If(Value(DataCardValue418.Text) >10 && Value(DataCardValue418.Text)<= 15, Color.Yellow,
If(Value(DataCardValue418.Text)> 15, Color.Green, Color.White)
)
)

If you feel that my response has helped you, please mark it as the solution and please consider giving it a thumbs up. This will help other community members find the solution quickly if they have a similar issue in the future.

4 REPLIES 4
Helper I

Hi @MarkFay1!

This link can help to use If and Switch, in this case, you need to use "If" for 3 results.

You can use this:
If(Value(DataCardValue418.Text)<= 10, Color.Red, Value(DataCardValue418.Text) <= 15, Color.Yellow, Color.Green)

Resolver II

Try this:

If(Value(DataCardValue418.Text)<= 10, Color.Red,
If(Value(DataCardValue418.Text) >10 && Value(DataCardValue418.Text)<= 15, Color.Yellow,
If(Value(DataCardValue418.Text)> 15, Color.Green, Color.White)
)
)

If you feel that my response has helped you, please mark it as the solution and please consider giving it a thumbs up. This will help other community members find the solution quickly if they have a similar issue in the future.

Frequent Visitor

Thank you SimmnaJ that worked.

Ygor, I will also play with the switch some more, wasnt able to get it to work either but not much experience with switch command. I tried;

Switch(
(Value(DataCardValue418.Text)),
<= 10, Color.Red,
<= 15, Color.Yellow,
>15, Color.Green
)

Didnt like that.

Helper I

Great, I was reminding you that you can also use Switch for some conditions. In my answer I made a simple code that works and you could use.

Announcements

#### Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.