Hello,
I would appreciate some assistance, i am trying do an IF statement on Power apps where by i am doing a subtraction calculation on a textbox by minus 8 but if a number is negative it defaults to 0 so as not to bring some total calculations issues. I cannot seem to get the formula right.
the explanation should be "if overtime hours is less that 0 then overtime text box should be 0, otherwise subtract 8 hours from the paid hours text box" i hope this explanation helps
Thank you
Hi @Gochix
Thank you so much! This has worked! i think my explanation was not good in the beginning. This solution works perfectly
@TYNAI ,
Sorry. If you say that you have txtPaidHours-8 as Default property for txtOTHours then change it to:
If(txtPaidHours-8 < 0,0,txtPaidHours-8)
_____________________________________________________________________________________
Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!
Hi @Gochix
The default of txtOTHours is already a hard coded 0, i have put the formula " txtPaidHours-8 " on the default calculation for txtOTHours it works well apart from giving the negative figures , based on this formula "txtPaidHours-8" is there an IF statement that will make all negative numbers to be 0 once "txtPaidHours-8" is run. I have tried putting the
If(Value(txtOTHours.Text) < 0,Reset(txtOTHours))
on the on change part. but it still shows the negative figures
@TYNAI ,
You can set the Default value for txtOTHours to 0.
Then OnChange property set to :
If(Value(txtOTHours.Text) < 0,Reset(txtOTHours))
This might not be a solution if you already have a Default property set for txtOTHours..
_____________________________________________________________________________________
Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!
Hi @Gochix
For your questions.
1) Looks like you have placed the formula in one of the text labels - txtOTHours? Yes this is correct
2) a text input field or Text Label? Text Input field
3)Where you want to display the final calculation? In other Text Label? The final calculation i.e setting negative number to be 0 should be in the txtOTHours
4)Just to clarify this, where you getting the data of txtOTHours and txtPaidHours? The txtPaidHours is preset text input field of 8 hours, while the txtOTHours is gotten from a calculation of difference in time on the app
"if overtime hours is less that 0 then overtime text box should be 0, otherwise subtract 8 hours from the paid hours text box"
Basically i want the text input on the txtOTHours to only display positive numbers, since the app calculates overtime hours. Having a negative number will impact on the total number of hours
Looks like you have placed the formula in one of the text labels - txtOTHours?
Just to clarify this, where you getting the data of txtOTHours and txtPaidHours? - a text input field or Text Label?
Where you want to display the final calculation? In other Text Label?
I can't understand the part of :
"if overtime hours is less that 0 then overtime text box should be 0, otherwise subtract 8 hours from the paid hours text box"
Hello @Gochix
Thank you for the assist, seems there is something up with the formula, i have gotten this error when i applied the code. I am not sure what it means
Hi @TYNAI ,
If(Value(txtOTHours.Text) - Value(txtPaidHours.Text) < 0,txtPaidHours-8,0)
Based on Text Labels.
Adjust for yourself how you need this to deduct the hours.
_____________________________________________________________________________________
Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional