Using IFERROR, IF and COUNTIF in one time

Hello everyone, as you can see i am trying to use this formula to calculate the day payment for Sickness and Holidays, i am using this formula. My question is how can i use the same formula in the same cell. so, when i select SICK or HOLIDAYS i will get the total. like is there any way to use it twice. thank you and i hope you understood what i mean.


IFERROR(IF(COUNTIF(1 Dec 2023 Situation;"Sick");Table 3::$A$2×8;1 Dec 2023 Working hours×Table 3::$A$2);"…")

MacBook Pro 13″, macOS 13.0

Posted on Nov 24, 2023 12:28 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 24, 2023 1:24 PM

This should work.


=IFERROR(Table 3::$A$2×IF(OR(1 Dec 23 Situation="Sick", 1 Dec 23 Situation="Holiday"),8,DUR2HOURS(1 Dec 23 Working hours)),"...")


This assumes that you are paid 8 hours for both sick days and vacations, at the same hourly rate.


16 replies

Nov 25, 2023 9:28 AM in response to Astr0phile

The problem with you formula is that is is, in my opinion, mis-using countif() inside of another IF. It is confusing and not necessary,


Change the formula in G2 to:

=IFERROR(IF(OR(C2="Sick", C2="Holiday"),8,DUR2HOURS(F2))×XLOOKUP(C2, Rates::A, Rates::B, "Choose a work type",match-type,search-type), "")


then fill down. This will force work hours to 8 on the days you enter "Sick" or "Holiday"



Nov 25, 2023 6:28 AM in response to Astr0phile

I suggest trying a different method:


1) create a small table where your various work rates go:

I am unclear, based on your example that the "Extra Work" makes sense. if you are really working for 17.243 Euros for regular pay, then dropping to 10 for extra you should NOT take extra work (this is my opinion). So maybe this is supposed to be pay on top of regular pay. In which case the formulas will be a little different.




2) Create a single table where you enter your work:



enter two subsequent dates in cells A2 and A3, then select the two dates. Hover the cursor over the bottom edge of the selection. click and hold on the yellow fill control that appears. Drag down as needed


select cell B2, then type (or copy and paste from here) the formula:

=DAYNAME(1+MOD(ROW()−1, 7))


short hand for this formula is:

B2=DAYNAME(1+MOD(ROW()−1, 7))



I notice you are from the EU. In this case you should modify the formulas I post to use the semicolon as the delimiter... like this:

=DAYNAME(1+MOD(ROW()−1; 7))


to fill down, select cell B2, copy

select cells B2 thru the end of columnB, paste


Create a pop up menu from the table Rate for the type of work. Select a cell with that pop-up menu and use it for the Work Type column (column C)



Looks like you get a 45 minute break in an Regular work shift and that regular hours are limited to 8 hours.

F2=IF(COUNTA(D2:E2)>1, MIN("8h", E2−D2), "")


G2=IFERROR(DUR2HOURS(F2)×XLOOKUP(C2, Rates::A, Rates::B, "Choose a work type"), "")

H2=IFERROR(IF((E2−D2)>DURATION(weeks,days,8,45),(E2−D2)−DURATION(weeks,days,8,45), ""), 0)

I2=IFERROR(DUR2HOURS(H2)×XLOOKUP("Extra Work Rate", Rates::A, Rates::B, 0), 0)

J2=IFERROR(I2+G2, "")


Select F2 then J2, copy

select F2 thru the end of column J, paste


Be careful here:

K8=IF(B8="Sunday",SUM(J2:J8), "")


select cell K8, copy

select cells K8 thru the end of column K, paste



DO NOT FORGET... replace the commas in my formulas with semicolons







Nov 26, 2023 6:05 AM in response to Astr0phile

In your first post, you had the formula in the column with 1 Dec 23 in the header.




That's why I reproduced exactly your situation to make it easier to just paste the formula at the same location (and then extend it to other columns, which would have adjusted the references).



But you used my formula in a column with a different header, hence the reason why it didn't work. You need to understand the formulas posted as solutions and adjust to your particular situation.


1 Dec 23 Working Hours is at the intersection of column 1 Dec 23 and row Working Hours.

Nov 24, 2023 12:41 PM in response to Astr0phile

repost your table with more dat entries and expected results. If you do not want to share specifics of your situation, make up some numbers that are representative.


Also... please show the other tables your formula uses as those often help us understand your problem and present a solution for you


Finally, describe what you want in each situation leave out the formulas you think you should use just describe what you want in words

Nov 24, 2023 1:14 PM in response to Wayne Contello

in the first screenshot you can see the whole month calendar, in the second one you can see the formula i am using to calculate the payment of sick days.

i have a pop-up menu with

  • ...
  • Present at work
  • Sick
  • Holidays
  • Unemployment
  • Allowed break
  • Appointments


i used this formula


IFERROR(IF(COUNTIF(1 Dec 2023 Situation;"Sick");Table 3::$A$2×8;1 Dec 2023 Working hours×Table 3::$A$2);"…")


to calculate the sum of the sick day because it's paid in full that means when i choose sick from the pop-up menu i get the total amount in euro. now my question is how can i have the same thing when i choose Holidays from the top-up menu ??


i want the cell of Gross salary to be the cell where i have the total payment when i work, when i am sick and when i am in holidays. example in the third screenshot


when i choose present at work i won't get anything in gross salary cell till choose what time i started the shift and the end.

when i choose sick i don't have to do anything else because i won't work but the gross salary cell will have the payment

when i choose holidays i want to do the same like when i am sick. no start and end shift but paid anyway.





i hope i didn't write too much, thank you in advance.

Nov 24, 2023 2:16 PM in response to Recycleur

Best Recycleur, unfortunately the formula you gave me it did not work. i made a screen recording but i can't send it here. when i used this formula of yours nothing happened. even when i choose sick or holidays from the pop-up menu. i hope there will be another solution for this. as you can see i am using your formula on the cell i selected but nothing happened


and about the payment of my sick and holidays is 100% as i am working 8 hours that's why i used this formula

IFERROR(IF(COUNTIF(1 Dec 2023 Situation;"Sick");Table 3::$A$2×8;1 Dec 2023 Working hours×Table 3::$A$2);"…")


Nov 25, 2023 7:02 AM in response to Wayne Contello

I would like to correct a formula and add a feature I missed:


H2=IFERROR(IF((E2−D2)>DURATION(weeks,days,8,45),(E2−D2)−DURATION(weeks,days,8,45), "0h"), "0h")


fill this down as needed.



You may summarize a single year using the following table:

Create a new table named "Summary" enter row A as shown


A2=ROW()−1&"/1/"&RIGHT(A$1, 4)


I have entered this for US dates... so I will explain the pieces so you can modify if needed:

Month is "ROW()−1"

Day is always 1

Year is obtained using "Right(A$1, 4)" (the 4 rightmost characters of the string in cell A1)


B2=SUMIFS(Table 3::F,Table 3::$A, ">="&DATE(YEAR($A2), MONTH($A2), 1), Table 3::$A, "<="&EOMONTH(DATE(YEAR($A2), MONTH($A2), 1),0))


C2=SUMIFS(Table 3::H,Table 3::$A, ">="&DATE(YEAR($A2), MONTH($A2), 1), Table 3::$A, "<="&EOMONTH(DATE(YEAR($A2), MONTH($A2), 1),0))


select cells A2 thru C2, copy

select cells A2 thru C13, paste

Nov 25, 2023 8:32 AM in response to Wayne Contello

Best Wayne Contello,


Thank you for your explanation. about the extra time! thanks for your opinion it is also my opinion lol, i only use it to count the hours i worked extra so i can take FREE time when i need to rest. i am all new to this. so, i am going to try what you told me and see if it is something what i need. Meanwhile is there any way to use my formula


IFERROR(IF(COUNTIF(1 Dec 2023 Situation;"Sick");Table 3::$A$2×8;1 Dec 2023 Working hours×Table 3::$A$2);"…")



and duplicate it to have the same formula works on Sick and Holidays.


for example:


IFERROR(IFOR(COUNTIF(1 Dec 2023 Situation;"Sick");Table 3::$A$2×8;1 Dec 2023 Working hours×Table 3::$A$2);"…");(COUNTIF(1 Dec 2023 Situation;"Holidays");Table 3::$A$2×8;1 Dec 2023 Working hours×Table 3::$A$2);"…")


this is only an example of what i mean i know maybe it's a wrong Formula.


i hope i'll hear from you soon.

Nov 25, 2023 9:07 AM in response to Wayne Contello

This formula i have

IFERROR(IF(COUNTIF(1 Dec 2023 Situation;"Sick");Table 3::$A$2×8;1 Dec 2023 Working hours×Table 3::$A$2);"…")

is working perfect but the problem is. it only works when i choose Sick situation from the pop-up menu. i want it to work also when i choose Holidays



that means if i choose Sick it will do for example:


my hour payment which is 17,2430× 8 hours = 137,944. so, the cell of Gross Salary will have +137,944 € . Because i get paid when i am sick


and if i choose Holidays it will do for example:


my hour payment which is 17,2430× 8 hours = 137,944. so, the cell of Gross Salary will have +137,944 € . Because i get paid when i am on holidays


and when i choose Present at work it won't do anything till i choose the start Shift time and the end Shift time. then the cell of the Gross Salary will have the total payment of the hours i worked.


if there is anyway to share a screen recording of the sheet i have please tell me how then i will do it maybe you can help me better. Thank you so much for your time.



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using IFERROR, IF and COUNTIF in one time

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.