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

If Statement Help

Hi guys

 

First off...this community has been amazing and the help...Wow!

Here's what I'm trying to do: 

 

I'm trying to get a label (Lable2) that says "Congratulations" to be visible when someone inputs more than 120 minutes of coaching in my app. The error that I'm getting is that it's expecting a numerical value. Not sure how to make it work. How do I get the "159" total on my screen to be reflected as a numerical value in the argument? 

 

The 159 is Sum(Gallery1.AllItems,Subtitle3.Text) for the gallery that you see on the screen. 

 

Thoughts? 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Solution Sage
Solution Sage

Re: If Statement Help

The text in a label is just that: text. You want Value().

If(Value(Label1.Text)>=120,true,false)

 

But let me also point out that your visible property simply expects a Boolean (true/false)... which the test case in your If() statement produces even without the If() structure... so just put that in the property. If you want a control to be visible if the label shows at least 120, then the Visible property would be:

Value(Label1.Text)>=120

View solution in original post

4 REPLIES 4
Highlighted
Super User III
Super User III

Re: If Statement Help

Hi @smartin ,

The easiest way to convert text to a number is to multiply it *1 (ie Label1.Text*1).   This does the same as using the Value(Label1.Text) function. If you want to convert time to a number, the DateDiff() function does that ie DateDiff(Start,End, Minutes).  

Highlighted
Solution Sage
Solution Sage

Re: If Statement Help

The text in a label is just that: text. You want Value().

If(Value(Label1.Text)>=120,true,false)

 

But let me also point out that your visible property simply expects a Boolean (true/false)... which the test case in your If() statement produces even without the If() structure... so just put that in the property. If you want a control to be visible if the label shows at least 120, then the Visible property would be:

Value(Label1.Text)>=120

View solution in original post

Highlighted
Helper I
Helper I

Re: If Statement Help

Thanks for that. It was exacltly what i needed. 

 

Do you know how I would turn that into a function that would let me send an email once the formua runs for what you shared? 

Highlighted
Solution Sage
Solution Sage

Re: If Statement Help

"Once the formula runs" is a little counter-model to the way PowerApps works. The formula is in the Visible property of a control, so it is being tested all the time. If you wanted to send an email only if the condition was met, you can arrive at that a couple of ways...

 

...put the SendEmail() statement in the "true" portion of an If() statement in a Button's OnSelect property, where the If() utilizes the same test as above.

 

...put the SendEmail() statement in a Button's OnSelect property, and set the Button's Visible property to be the same test, as above (that way, the user can only run it if the conditions are correct).

 

As for sending the email, you're going to need the Office365 Outlook Connector. Once you have it, the formula is fairly straightforward:

Office365.SendEmail(yourRecipientAddress, yourSubjectLine, yourMessageBody)

Any of those things can be supplied from controls in your app (or a datasource that defines recipients), and there are ways to send multiple messages or to multiple recipients.

 

Post back if you need more help.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,516)