SOLVED

Excel SUMIF with OR or something?

%3CLINGO-SUB%20id%3D%22lingo-sub-2865320%22%20slang%3D%22en-US%22%3EExcel%20SUMIF%20with%20OR%20or%20something%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2865320%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20everyone.%26nbsp%3B%20I%20hope%20you%20can%20help.%26nbsp%3B%20I%20need%20to%20calculate%20the%20number%20of%20hours%20worked%20on%20a%20spreadsheet%20sent%20to%20me%20by%20a%20client.%26nbsp%3B%20The%20worksheet%20calculates%20the%20number%20of%20working%20days%20in%20the%20sheet%20and%20multiplies%20it%20by%209%20to%20get%20the%20total%20hours%20for%20the%20month.%26nbsp%3B%20If%20the%20hours%20worked%20are%20more%20than%20the%20monthly%20hours%2C%20then%20those%20hours%20need%20to%20go%20to%20the%20Overtime%20column.%26nbsp%3B%20HOWEVER%2C%20if%20the%20staff%20member%20has%20taken%20Leave%2C%20Sick%20Leave%20or%20Family%20Leave%20that%20is%20regarded%20as%20paid%20so%20the%20spreadsheet%20needs%20to%20count%20the%20number%20of%20days%20marked%20A%2C%20S%20or%20F%20and%20mutliply%20that%20by%209%20hours%20as%20well.%26nbsp%3B%20If%20the%20hours%20including%20A%2CS%20or%20F%20are%20more%20than%20the%20hours%20for%20the%20month%2C%20then%20the%20overtime%20hours%20need%20to%20kick%20in.%3C%2FP%3E%3CP%3EI%20used%20the%20following%20formula%20and%20it's%20not%20working.%26nbsp%3B%20I%20am%20tearing%20my%20hair%20out!!%20HELP.............%3C%2FP%3E%3CP%3ECalculate%20total%20hours%20worked%3A%26nbsp%3B%3DIF(SUM(SUMIF(%24A%241%3A%24AE%241%2C%7B2%2C3%2C4%2C5%2C6%7D%2C%24A4%3A%24AE4)%2BSUM(COUNTIFS(%24A4%3A%24AE4%2C%7B%22A%22%2C%22S%22%2C%22U%22%2C%22F%22%7D)*9))%26gt%3B%3D%24AF%242%2C%24AF%242%2CSUM(SUMIF(%24A%241%3A%24AE%241%2C%7B2%2C3%2C4%2C5%2C6%7D%2C%24A4%3A%24AE4)%2BSUM(COUNTIFS(%24A4%3A%24AE4%2C%7B%22A%22%2C%22S%22%2C%22U%22%2C%22F%22%7D)*9)))%3C%2FP%3E%3CP%3ECalculate%20Overtime%3A%26nbsp%3B%26nbsp%3B%3DIF(SUM(SUMIF(%24A%241%3A%24AE%241%2C%7B2%2C3%2C4%2C5%2C6%7D%2C%24A4%3A%24AE4))%26lt%3B%3D%24AF%242%2C0%2CSUM(SUMIF(%24A%241%3A%24AE%241%2C%7B2%2C3%2C4%2C5%2C6%7D%2C%24A4%3A%24AE4))-%24AF%242)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2865320%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2865637%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20SUMIF%20with%20OR%20or%20something%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2865637%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1165610%22%20target%3D%22_blank%22%3E%40ShazzieH%3C%2FA%3E%26nbsp%3Bmay%20I%20suggest%20a%20different%20approach%20to%20use%20MIN%20and%20MAX%20to%20constrain%20those%20output%20instead%3A%3C%2FP%3E%3CP%3E%3CSPAN%3ECalculate%20total%20hours%20worked%3A%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DMIN(SUM(SUMIF(%24A%241%3A%24AE%241%2C%7B2%2C3%2C4%2C5%2C6%7D%2C%24A5%3A%24AE5)%2BSUM(COUNTIFS(%24A5%3A%24AE5%2C%7B%22A%22%2C%22S%22%2C%22U%22%2C%22F%22%7D)*9))%2C%24AF%242)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CSPAN%3ECalculate%20Overtime%3A%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DMAX(SUM(SUMIF(%24A%241%3A%24AE%241%2C%7B2%2C3%2C4%2C5%2C6%7D%2C%24A5%3A%24AE5))%2BSUM(COUNTIFS(%24A5%3A%24AE5%2C%7B%22A%22%2C%22S%22%2C%22U%22%2C%22F%22%7D))*9-%24AF%242%2C0)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2865694%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20SUMIF%20with%20OR%20or%20something%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2865694%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%26nbsp%3Bmany%20thanks.%26nbsp%3B%20I%20will%20try%20this%20tomorrow%20and%20let%20you%20know.%26nbsp%3B%20Thank%20you%20for%20the%20suggestion%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%20Sharon%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi everyone.  I hope you can help.  I need to calculate the number of hours worked on a spreadsheet sent to me by a client.  The worksheet calculates the number of working days in the sheet and multiplies it by 9 to get the total hours for the month.  If the hours worked are more than the monthly hours, then those hours need to go to the Overtime column.  HOWEVER, if the staff member has taken Leave, Sick Leave or Family Leave that is regarded as paid so the spreadsheet needs to count the number of days marked A, S or F and mutliply that by 9 hours as well.  If the hours including A,S or F are more than the hours for the month, then the overtime hours need to kick in.

I used the following formula and it's not working.  I am tearing my hair out!! HELP.............

Calculate total hours worked: =IF(SUM(SUMIF($A$1:$AE$1,{2,3,4,5,6},$A4:$AE4)+SUM(COUNTIFS($A4:$AE4,{"A","S","U","F"})*9))>=$AF$2,$AF$2,SUM(SUMIF($A$1:$AE$1,{2,3,4,5,6},$A4:$AE4)+SUM(COUNTIFS($A4:$AE4,{"A","S","U","F"})*9)))

Calculate Overtime:  =IF(SUM(SUMIF($A$1:$AE$1,{2,3,4,5,6},$A4:$AE4))<=$AF$2,0,SUM(SUMIF($A$1:$AE$1,{2,3,4,5,6},$A4:$AE4))-$AF$2)

 

 

3 Replies
best response confirmed by ShazzieH (New Contributor)
Solution

@ShazzieH may I suggest a different approach to use MIN and MAX to constrain those output instead:

Calculate total hours worked:

=MIN(SUM(SUMIF($A$1:$AE$1,{2,3,4,5,6},$A5:$AE5)+SUM(COUNTIFS($A5:$AE5,{"A","S","U","F"})*9)),$AF$2)

Calculate Overtime: 

=MAX(SUM(SUMIF($A$1:$AE$1,{2,3,4,5,6},$A5:$AE5))+SUM(COUNTIFS($A5:$AE5,{"A","S","U","F"}))*9-$AF$2,0)

 

@mtarler many thanks.  I will try this tomorrow and let you know.  Thank you for the suggestion

 

Regards, Sharon

Oh wow! I don't know why I didn't think of MIN and Max but it WORKS Thank you very much for you help. I really appreciate it