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 blog
Power Automate Video Tutorials

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.
Anonymous
Not applicable

Hi there,

 

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

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (4,154)