cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Use the Fill property based on a field containing either a letter, number or both

I have fields that contain results from analysis.

The analysis required, is indicated by an 'x', which changes the Fill to red.

When analysis is entered, it overrides the 'x' and the field will revert back to white.

What I am hoping to do, is add another condition, whereby if a field contains both a letter and numbers, it will change to blue.

Some analysis results have letters but never both. Results with numbers do have decimal points (all fields are stored as text).

 

 

If(TextInput1_12.Text="x", RGBA(217, 134, 134, 1),RGBA(255, 255, 255, 1))

 

 The above is what I have so far.... 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Use the Fill property based on a field containing either a letter, number or both

Hey @LabDude, one thing you could do is utilize the ability to add multiple conditions to an If statement. Something like:

If(
    TextInput1_12.Text = "x", 
    RGBA(217, 134, 134, 1),
    *some other condition*,
    RGBA(0, 0, 255, 1),
    RGBA(255, 255, 255, 1)
)

If you have a specific pattern that the field you want to check matches against, you could use the IsMatch function to check for that pattern. It sounds like you might be after something like this:

If(
    TextInput1_12.Text = "x", 
    RGBA(217, 134, 134, 1),
    IsMatch( 
        TextInput1_12.Text, 
        Letter & MultipleDigits & Period & OptionalDigits 
    ),
    RGBA(0, 0, 255, 1),
    RGBA(255, 255, 255, 1)
)

I haven't tested the code above but it should check for x and use the corresponding color. Then if the text is not exactly x, check the text to see if there is a letter, one or more digits, a period, and then zero or more digits and if so, use blue. If neither of those conditions evaluate to true, use white.

The link provided above should give you a good start on that function if the above code isn't what you are after but if you could use some more assistance, feel free to reply to this thread and I'll be happy to follow up!

View solution in original post

3 REPLIES 3
Highlighted
Super User
Super User

Re: Use the Fill property based on a field containing either a letter, number or both

Hey @LabDude, one thing you could do is utilize the ability to add multiple conditions to an If statement. Something like:

If(
    TextInput1_12.Text = "x", 
    RGBA(217, 134, 134, 1),
    *some other condition*,
    RGBA(0, 0, 255, 1),
    RGBA(255, 255, 255, 1)
)

If you have a specific pattern that the field you want to check matches against, you could use the IsMatch function to check for that pattern. It sounds like you might be after something like this:

If(
    TextInput1_12.Text = "x", 
    RGBA(217, 134, 134, 1),
    IsMatch( 
        TextInput1_12.Text, 
        Letter & MultipleDigits & Period & OptionalDigits 
    ),
    RGBA(0, 0, 255, 1),
    RGBA(255, 255, 255, 1)
)

I haven't tested the code above but it should check for x and use the corresponding color. Then if the text is not exactly x, check the text to see if there is a letter, one or more digits, a period, and then zero or more digits and if so, use blue. If neither of those conditions evaluate to true, use white.

The link provided above should give you a good start on that function if the above code isn't what you are after but if you could use some more assistance, feel free to reply to this thread and I'll be happy to follow up!

View solution in original post

Highlighted
Helper I
Helper I

Re: Use the Fill property based on a field containing either a letter, number or both

Thanks @wyotim this worked perfectly - I was trying the IsMatch, but wasn't structuring the code properly.....great help!

 

Highlighted
Super User
Super User

Re: Use the Fill property based on a field containing either a letter, number or both

Happy to assist! Feel free to hit me up if I can help out in the future!

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (13,806)