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!

16 REPLIES 16

Is there a max number of digits after the decimal?

I have not enforced a certain number of digits after the decimal, but could if its easiest.

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

Thank you very much for your prompt assistance. Very helpful solution.
Good day!

Glad I could help! Good luck with the rest of the app! Feel free to reach out in case of any questions!

Thanks,
Hardit Bhatia
https://thepoweraddict.com

Nice job @PowerAddict. I learned something new by reviewing your post. Your technique for regex is slightly different than what I am used to in a neat way!

Thanks @mdevaney!

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 (66,173)