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

Combine If statements

Hi there, 

I am in the situation that i have two If Statements that works very well individually, however i would like to combine them in a way that powerapps would be able to check both parameters before returning true;false or in this case Disabled;Edit. 

1. 

If(TimeValue(Text(Now()))>Time(09,45,00),Disabled,Edit)
//Decides whether a button should be pressable based on the current time of the day, in this case whether the time has surpassed 09:45, if yes, disable if no, edit. 

 

2.

If(Weekday(Now(),Monday)>=3,Disabled,Edit)
/7Checks if the dau has surpassed a specific day of the week, in this case wednesday, and decides whether the button should be editable based on this. 

These are the two statements thatI would like to combine into one statement, in order for powerapps to check both things before  returning. So that it would be able to disable a button if the time has surpassed 0945 on a monday but leave another editable until 0945 on wednesday. 

Essentially first check what day it is (1-7) and then check the time and return a value. 

hope you can help. 
- Tobias 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

Re: Combine If statements

Hey @TCH 

 

can you try to combine the expressions as:
 
If(TimeValue(Text(Now()))>Time(09,45,00) && Weekday(Now(),Monday)>=3,Disabled,Edit)
 
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Highlighted
Responsive Resident
Responsive Resident

Re: Combine If statements

Hi @TCH,

 

Just to explain @yashag2255's answer a bit, there is the And() function, which only returns true when all statements are satisfied as true within it. The && operator is just a different way to say the same thing.

 

If(TimeValue(Text(Now()))>Time(09,45,00) && Weekday(Now(),Monday)>=3,Disabled,Edit) 

is the same as 

If(And(TimeValue(Text(Now()))>Time(09,45,00),Weekday(Now(),Monday)>=3),Disabled,Edit)

 

There is also the Or() function, or ||, returns true when any of the statements are true.

 

Finally, there is Not(), or !, which inverts the result. The ! must precede the statement you want to invert. You can place it before individual statements or before the And() and Or() functions to invert the entire result.

View solution in original post

4 REPLIES 4
Highlighted
Dual Super User III
Dual Super User III

Re: Combine If statements

Hey @TCH 

 

can you try to combine the expressions as:
 
If(TimeValue(Text(Now()))>Time(09,45,00) && Weekday(Now(),Monday)>=3,Disabled,Edit)
 
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Highlighted
Responsive Resident
Responsive Resident

Re: Combine If statements

Hi @TCH,

 

Just to explain @yashag2255's answer a bit, there is the And() function, which only returns true when all statements are satisfied as true within it. The && operator is just a different way to say the same thing.

 

If(TimeValue(Text(Now()))>Time(09,45,00) && Weekday(Now(),Monday)>=3,Disabled,Edit) 

is the same as 

If(And(TimeValue(Text(Now()))>Time(09,45,00),Weekday(Now(),Monday)>=3),Disabled,Edit)

 

There is also the Or() function, or ||, returns true when any of the statements are true.

 

Finally, there is Not(), or !, which inverts the result. The ! must precede the statement you want to invert. You can place it before individual statements or before the And() and Or() functions to invert the entire result.

View solution in original post

Highlighted
Helper IV
Helper IV

Re: Combine If statements

@chrisog @yashag2255 

I was so close to getting there myself, i just needed to switch a few things, but this makes perfect sense thank you so much! 

Highlighted
Helper IV
Helper IV

Re: Combine If statements

@chrisog @yashag2255 

Hi again, 

It does not really seem to work, i have tried 

 

If(!And(TimeValue(Text(Now()))>Time(09;30;00);Weekday(Now();Monday)>=2);Disabled;Edit)



If(TimeValue(Text(Now()))>Time(09;30;00) && Weekday(Now();Monday)>=2;Disabled;Edit)



If(TimeValue(Text(Now()))>Time(09;30;00) && Weekday(Now();Monday)>=2;Disabled;Edit)

 

 

If(Weekday(Now();Monday)>=2;Disabled;Edit && TimeValue(Text(Now()))>Time(09;30;00))



If(Weekday(Now();Monday)>=2 && TimeValue(Text(Now()))>Time(09;30;00);Disabled;Edit)

 

In all cases it should check if the date is tuesday and whether the time is before or after 0930, and then return true or false based on both these coniditions. However, it does not really do this, it only checks for the first condition and then it sort of fails to check the other one, meaning that today friday, if I set any of the above functions with the time condition first to 1030 it will only check for this and return true, it does not take into acount whether it is also tuesday or not, of course this function should be disabled from wednesday on, until monday where a new week begins? 

Do you have any suggestions on how to optimize this or why this error might occur, or is it simply just not possible to create this function within PowerApps 🙂 

- Tobi 

 

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,518)