cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Memorable Member
Memorable Member

Search for a number within a label?

Scenario:

  • Gallery with a multiline label (lblDuration)
  • Sample lblDuration text:
    • "This REST service took 50 seconds to execute."
  • I'd like to set lblDuration Fill based on the number found in the text
  • Something like: If(Find(lblDuration, > Value("10")), Red, LightGray)
    • Which would highlight lblDuration if there is a number greater than 10 found in the text.

The above sample using Find() doesn't work. Neither does Search().
Any other ideas?
THank you!

1 ACCEPTED SOLUTION

Accepted Solutions

So say if the only two formats allowed are whole number or with one decimal place, you could use something like: 

 

If(Value(Match(Label28.Text, (Digit & "\." & Digit)).FullMatch)>3 || Value(Match(Label28.Text, "\d+").FullMatch)>3, Red, Gray)

 

Here is a demo: 

 

Format1.gif

 

You can easily factor in other formats if needed, like 2 decimal places or even 3 by adding more OR conditions. 

 

Let me know if this helps. 

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://www.thepoweraddict.com

View solution in original post

16 REPLIES 16
Super User II
Super User II

Will the number always be at a fixed spot? In other words, is the format of that text well defined? Or could the number be anywhere in the string?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com

Hello @PowerAddict , I appreciate your quick response. The answer is no, the content is not structured in a way to utilize string manipulation.

No problem. One more question: is there an expected range of values e.g. max will be 99?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com

Here you go:

Set the fill property to something like this:

If(Value(Match(Label28.Text, "\d+").FullMatch)>10, Red, RGBA(0, 0, 0, 0))

Label28 is where my text is. I used your example: This REST service took 50 seconds to execute. You can replace Label28 with your label or wherever the text is. Also, I used Red or No Fill. You can replace RGBA(0,0,0,0) with Gray.

Let me know if this works.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://www.thepoweraddict.com

A quick demo:

Format.gif

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://www.thepoweraddict.com

Hi @PowerAddict . Thank you.

I see the solution working in your demo, however porting it to my application doesn't seem to work.

lblGalDuration is the label in the gallery. As you can see, it holds a value of "0.25" in the label. I've lowered the value in the function to "0.1" but it does not trigger...

 

image.png

No problem.

Two questions:
1. Is lblGalDuration where your text is stored? Is it multi-line text? HTML text?
2. If you just put this expression in a label, what do you see?

Match(lblGalDuration.Text, "\d+").FullMatch

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://www.thepoweraddict.com

Also, your original post did not specify that the numbers will be in decimals. Will they always be in decimals or can they be in either format?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://www.thepoweraddict.com

1. Yes, lblGalDuration is where my text is stored. It is a multi-line label.

  a. I just changed the value to a whole number, 3. It flagged the "10.9" value, but not the "3.7" value.

  b. image.png

2. Placing Match(lblGalDuration.Text, "\d+").FullMatch in a label shows nothing, just blank.

image.png

3. Numbers may be whole or decimal.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (23,258)