[Solved] Add condition to IF

Discuss the spreadsheet application
Locked
User avatar
donnje
Posts: 81
Joined: Sun Apr 20, 2025 4:06 pm
Location: Italy

[Solved] Add condition to IF

Post by donnje »

Hi everyone,
I'd like to create a formula that works in all cases across time slots, so I think I'll need to modify E4

=SE(VAL.VUOTO(D4);C4-A4)

also adding the condition that B2 is blank

and then add the following formula that works in cases E1, E2, and E3

=SOMMA(D1-C1)+SOMMA(B1-A1)

Thanks
Last edited by donnje on Sat Feb 07, 2026 8:19 pm, edited 6 times in total.
LibreOffice 24.8.6.2
User avatar
RoryOF
Moderator
Posts: 35268
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Time Formula

Post by RoryOF »

In Row 12 is "Afternoon Entry" to be understood as the omitted "Morning outing"? And what happens when there is no "Afternoon outing" time specified?

You need to rethink your conditions and your formulae. The time is working correctly with valid zero cells in the earlier rows.
Apache OpenOffice 4.1.17 on Xubuntu 26.04.1 LTS
User avatar
donnje
Posts: 81
Joined: Sun Apr 20, 2025 4:06 pm
Location: Italy

Re: Time Formula

Post by donnje »

in line 12 the time is extended from 7:25 to 15:15
for G12, the formula is =SE(VAL.VUOTO(E12);D12-B12)
Now I need to figure out how to add the conditions for the other cells
LibreOffice 24.8.6.2
User avatar
donnje
Posts: 81
Joined: Sun Apr 20, 2025 4:06 pm
Location: Italy

Re: Add condition to IF

Post by donnje »

can anyone help me?
LibreOffice 24.8.6.2
User avatar
RoryOF
Moderator
Posts: 35268
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Add condition to IF

Post by RoryOF »

As I said before, reconsider your conditions and state these clearly.

What happens when there is no start time or no finish time for both morning and/or afternoon entries? We cannot read your mind.
Apache OpenOffice 4.1.17 on Xubuntu 26.04.1 LTS
User avatar
Lupp
Volunteer
Posts: 3761
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Add condition to IF

Post by Lupp »

donnje wrote: Wed Feb 04, 2026 6:26 pm can anyone help me?
Seems WE need help.
1. Enable "Use English function names" for your Calc formulas if you want to post your formulas to a forum in English language.
2. Attach a shortened example Calc-file (.ods) and explain there in detail what you want to achieve, then ...
3. Give examples for some cells showing the results you want to get there - based on calculations using a pencil and a sheet of paper.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Alex1
Volunteer
Posts: 853
Joined: Fri Feb 26, 2010 1:00 pm
Location: Netherlands, EU

Re: Add condition to IF

Post by Alex1 »

It looks like you deleted the original question. That makes it useless for other visitors with the same problem.
AOO 4.1.16 & LO 25.8.3 on Windows 10
User avatar
MrProgrammer
Moderator
Posts: 5480
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Add condition to IF

Post by MrProgrammer »

donnje please do not delete a question after it has been answered and replace it with a different one. This makes the topic very confusing to others who read it later. And if you want to review the initial discussion at some point, you won't be able to because it is gone. Once a question has been answered, the appropriate step is to mark it as [Solved]. Then if you have a new question, create a new topic for it. Please review our forum policy: One issue, one thread.

If you delete your original question in future topics, the forum moderators will have a discussion about banning you.
-- MrProgrammer, forum moderator

donnje wrote: Wed Feb 04, 2026 6:26 pm can anyone help me?
You are asking others to spend their time providing free help with your problem. You are more likely to get it resolved quickly by following these guidelines:
• Attach a spreadsheet to demonstrate the problem. Even if you explain the problem in detail, volunteers here will want to test solutions. You make it easier for them if they don't have to create their own spreadsheet to do the testing, and they can test with your data.
• Provide English function names in any formulas you put in your posts. This is an English-speaking forum. When you provide formulas in Italian, people need to spend extra time understanding your post. I'd guess a lot of people will just ignore these posts. When you attach your spreadsheet, instead of typing the function in a post, OpenOffice will perform the translation automatically and will display formulas in the language which was set during installation. For me, I installed an English version of OpenOffice so all formulas in attached spreadsheets are displayed in English.

Since you are in the habit of not providing attachments, only screenshots, and putting Calc formulas in Italian, it's unlikely I will answer your questions. It just takes too much of my time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
donnje
Posts: 81
Joined: Sun Apr 20, 2025 4:06 pm
Location: Italy

Re: Add condition to IF

Post by donnje »

Sorry if I've created confusion, it won't happen again.
I'd like column G to calculate the duration in hours and minutes by entering any time in columns C, D, E, or F. I'd like to point out that the shifts entered will always be different.
I'm attaching the file.
Thanks
Attachments
PROVA.ods
(13.31 KiB) Downloaded 542 times
LibreOffice 24.8.6.2
User avatar
Lupp
Volunteer
Posts: 3761
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Add condition to IF

Post by Lupp »

PROVA.ods
(20.82 KiB) Downloaded 775 times
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
donnje
Posts: 81
Joined: Sun Apr 20, 2025 4:06 pm
Location: Italy

Re: Add condition to IF

Post by donnje »

Great
In line F, it means that the shift starts at 7:25 and ends at 15:15, so in G12 = 7:50, can you fix that?
Thanks
LibreOffice 24.8.6.2
Alex1
Volunteer
Posts: 853
Joined: Fri Feb 26, 2010 1:00 pm
Location: Netherlands, EU

Re: Add condition to IF

Post by Alex1 »

The values in row 12 are in the wrong cells. Put 07:25, 12:00, 12:00, 15:15 in cells C12:F12.
AOO 4.1.16 & LO 25.8.3 on Windows 10
User avatar
donnje
Posts: 81
Joined: Sun Apr 20, 2025 4:06 pm
Location: Italy

Re: Add condition to IF

Post by donnje »

thanks worked
LibreOffice 24.8.6.2
User avatar
donnje
Posts: 81
Joined: Sun Apr 20, 2025 4:06 pm
Location: Italy

Re: Add condition to IF

Post by donnje »

Alex1 wrote: Sat Feb 07, 2026 11:55 am The values in row 12 are in the wrong cells. Put 07:25, 12:00, 12:00, 15:15 in cells C12:F12.
I'm afraid of getting confused, is there a way to leave cells D12 and E12 blank?
LibreOffice 24.8.6.2
User avatar
Lupp
Volunteer
Posts: 3761
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Add condition to IF

Post by Lupp »

donnje wrote: Sat Feb 07, 2026 3:21 pm I'm afraid of getting confused, is there a way to leave cells D12 and E12 blank?
Now I'm confused.
If you want to enter starting times of a shift once, and the ending times later, It's about columns D anf F (not E).

In principle you can leave any of the 4 time cells per day empty if you adapt the formulas in column F a bit.

The more serious problem would be a shift which starts before midnight of the previous day or ends after midnight of the current day. Every formula given assumes you assured that there cannot be three or more shifts.
A TimeOfDay without a date part can't sufficiently mark a point in time.
On the other hand it's meaningless for the evaluation of a shift if it is starting before noon or after.
aoo_555795_PROVA_B.ods
(21.67 KiB) Downloaded 537 times
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
donnje
Posts: 81
Joined: Sun Apr 20, 2025 4:06 pm
Location: Italy

Re: Add condition to IF

Post by donnje »

I'll try to explain better. There aren't any shifts after midnight, but I need to insert shifts that start in the morning and end in the evening, for example:

Shift1_Start = 7:25
Shift2_End = 15:15

I hadn't thought about putting 15:15 in Shift1_End rather than Shift2_End so that it would still work.
LibreOffice 24.8.6.2
Locked