[Solved] Subtract, but prevent negative result

Discuss the spreadsheet application
Locked
manicmailman
Posts: 2
Joined: Fri Nov 08, 2024 12:40 am

[Solved] Subtract, but prevent negative result

Post by manicmailman »

Novice LibreOffice user here looking for some help on how to do conditional subtraction. I have a spreadsheet of workhours for a week, and I want to make a formula that will take the raw workhours and subtract 11.50 to find total hours worked past the hourly limit of 11.50, but will ignore the function (or else zero it out) if they worked less than 11.50. Any help is appreciated!
Last edited by MrProgrammer on Thu Nov 21, 2024 7:34 am, edited 2 times in total.
Reason: Edited topic's subject
OpenOffice 24.2.3.2, Windows 11 Pro x64
FJCC
Moderator
Posts: 9624
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Raw Subtract If and conditional subtraction

Post by FJCC »

If your raw hours are in B2, this formula should work.

Code: Select all

=MAX(0;B2 - 11.5)
You will get zero if B2 is less than 11.5.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
manicmailman
Posts: 2
Joined: Fri Nov 08, 2024 12:40 am

Re: Raw Subtract If and conditional subtraction

Post by manicmailman »

Works like a charm! Thanks a lot!
OpenOffice 24.2.3.2, Windows 11 Pro x64
User avatar
robleyd
Moderator
Posts: 5505
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Raw Subtract If and conditional subtraction

Post by robleyd »

Or you could use IF():

Code: Select all

=IF(B2 < 11.5; 0; B2 - 11.5)
Slackware 15 (current) 64 bit
Apache OpenOffice 4.1.16
LibreOffice 26.2.3.2; SlackBuild for 26.2.3 by Eric Hameleers
---------------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
Locked