cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

If statement conditions not recognized.

This If statement is inside the Default section of a text input called txtTotalHours. It's a simple If statement that has 2 conditions. Condition one checks if a textbox is not empty. If it's not empty, the default value from the SharePoint database populates txtTotalHours. If it is empty, the default condition populates txtTotalHours by using the DateDiff calculation in the formula. The default condition does not work but condition 1 does work. See the If statement below:

 

If(!IsEmpty(txtNumber), Parent.Default, DateDiff(
Start.SelectedDate + Time(Value(StartHour.Selected.Value), Value(StartMinute.Selected.Value), 0),
End.SelectedDate + Time(Value(EndHour.Selected.Value), Value(EndMinute.Selected.Value), 0),
Hours) &
":" &
Mod(
DateDiff(
Start.SelectedDate + Time(Value(StartHour.Selected.Value), Value(StartMinute.Selected.Value), 0),
End.SelectedDate + Time(Value(EndHour.Selected.Value), Value(EndMinute.Selected.Value), 0),
Minutes),
60))

 

Any idea as to why the default condition won't work? I have tried many variations but no luck. I can provide more details if needs be.

 

Thanks. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Anonymous ,

Could you tell me what is the textbox?

Is a textinput control?

If so, you should use IsBlank to justify whether it is an empty value.

IsEmpty is used to justidy whether a table is an empty table.

Please try this formula:

If(!IsBlank(txtNumber.Text), Parent.Default, DateDiff(
Start.SelectedDate + Time(Value(StartHour.Selected.Value), Value(StartMinute.Selected.Value), 0),
End.SelectedDate + Time(Value(EndHour.Selected.Value), Value(EndMinute.Selected.Value), 0),
Hours) &
":" &
Mod(
DateDiff(
Start.SelectedDate + Time(Value(StartHour.Selected.Value), Value(StartMinute.Selected.Value), 0),
End.SelectedDate + Time(Value(EndHour.Selected.Value), Value(EndMinute.Selected.Value), 0),
Minutes),
60))

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
abm
Super User
Super User

Hi @Anonymous ,

 

Change If(!IsEmpty(txtNumber) to If(!IsEmpty(txtNumber.Text)

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials
yashag2255
Dual Super User II
Dual Super User II

Hi @Anonymous , 

 

Change the default value of your text input as below mentioned formula: 
If(IsBlank(txtTotalHours),DateDiff(Start.SelectedDate + Time(Value(Dropdown1.Selected.Value), Value(Dropdown1_1.Selected.Value), 0),
End.SelectedDate + Time(Value(Dropdown2.Selected.Value), Value(Dropdown2_1.Selected.Value), 0),
Hours) &
":" &
Mod(
DateDiff(
Start.SelectedDate + Time(Value( Dropdown1.Selected.Value), Value(Dropdown1_1.Selected.Value), 0),
End.SelectedDate + Time(Value( Dropdown2.Selected.Value), Value(Dropdown2_1.Selected.Value), 0),
Minutes),
60),Parent.Default) 
Also, replace Dropdown Name with your control Names.
 
There might be a problem with using isempty() because it searches for a response of type list/array.
MicrosoftTeams-image (45).png

 

 
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!
v-yutliu-msft
Community Support
Community Support

Hi @Anonymous ,

Could you tell me what is the textbox?

Is a textinput control?

If so, you should use IsBlank to justify whether it is an empty value.

IsEmpty is used to justidy whether a table is an empty table.

Please try this formula:

If(!IsBlank(txtNumber.Text), Parent.Default, DateDiff(
Start.SelectedDate + Time(Value(StartHour.Selected.Value), Value(StartMinute.Selected.Value), 0),
End.SelectedDate + Time(Value(EndHour.Selected.Value), Value(EndMinute.Selected.Value), 0),
Hours) &
":" &
Mod(
DateDiff(
Start.SelectedDate + Time(Value(StartHour.Selected.Value), Value(StartMinute.Selected.Value), 0),
End.SelectedDate + Time(Value(EndHour.Selected.Value), Value(EndMinute.Selected.Value), 0),
Minutes),
60))

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Hi there,

 

This seems to work quite well! Thanks for your solution. 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,186)