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

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

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

chrisog
Level 8

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

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

chrisog
Level 8

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

TCH
Level: Powered On

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! 

TCH
Level: Powered On

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
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 (Last 30 Days)
Users online (5,281)