cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
smartin
Level: Powered On

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
TimRohr
Level 10

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
Super User
Super User

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).  

TimRohr
Level 10

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

smartin
Level: Powered On

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? 

TimRohr
Level 10

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 265 members 6,056 guests
Please welcome our newest community members: