SumProduct with OR function

EMcK01

Board Regular
Joined
Jun 14, 2015
Messages
125
Hi,

I’ve been developing a spreadsheet given by a colleague that allows me to track annual leave, time off in lieu etc. The spreadsheet has been broken down to either note full day, half day am and half day pm.
I have 5 categories where someone could be absent either for the full day or either half and as such the spreadsheet records it this way. All the categories are located on column OH, these are referenced in summation calculation.

My issue is when it comes to summing days absent it is not doing so correctly when I enter a half day code. In cell NK8 it sums all leave taken in the year. I have “F” in cells B8 & C8 for fixed leave on 1st and 2nd January. if I enter “A” in cell D8 this then sums to 3 in cell NK8 which is correct. However if I change “A” to “A1” to represent absent for half day only, it changes the value in NK8 to 1.5 rather than 2.5.

I think it’s a silly error where I am applying the 0.5 factor to the total rather than just the limited cells but can’t see where to fix it. The formula I am using is this:

Code:
{=SUMPRODUCT((OFFSET($A8,0,1,1,372)<>"")*(IF(OR(OFFSET($A8,0,1,1,372)=$OH$9,(OFFSET($A8,0,1,1,372)=$OH$10),(OFFSET($A8,0,1,1,372)=$OH$13),(OFFSET($A8,0,1,1,372)=$OH$14),(OFFSET($A8,0,1,1,372)=$OH$16),(OFFSET($A8,0,1,1,372)=$OH$17),(OFFSET($A8,0,1,1,372)=$OH$19),(OFFSET($A8,0,1,1,372)=$OH$20),(OFFSET($A8,0,1,1,372)=$OH$22),(OFFSET($A8,0,1,1,372)=$OH$23)),0.5,IF(OR(OFFSET($A8,0,1,1,372)=$OH$9,(OFFSET($A8,0,1,1,372)=$OH$10),(OFFSET($A8,0,1,1,372)=$OH$13),(OFFSET($A8,0,1,1,372)=$OH$14),(OFFSET($A8,0,1,1,372)=$OH$16),(OFFSET($A8,0,1,1,372)=$OH$17),(OFFSET($A8,0,1,1,372)=$OH$19),(OFFSET($A8,0,1,1,372)=$OH$20),(OFFSET($A8,0,1,1,372)=$OH$22),(OFFSET($A8,0,1,1,372)=$OH$23)),0.5,1)*(OFFSET($A$3,0,1,1,372)))))}

Any help would be appreciated.

Thanks,
EMcK
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Thanks for the response, I'll try and explain what I am looking for as a reduced example.

If you consider February, with each day of the month having its own column. The table below considers the first two weeks of February as follows:

[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[TD]P[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]01[/TD]
[TD]02[/TD]
[TD]03[/TD]
[TD]04[/TD]
[TD]05[/TD]
[TD]06[/TD]
[TD]07[/TD]
[TD]08[/TD]
[TD]09[/TD]
[TD]10[/TD]
[TD]11[/TD]
[TD]12[/TD]
[TD]13[/TD]
[TD]14[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Thu[/TD]
[TD]Fri[/TD]
[TD]Sat[/TD]
[TD]Sun[/TD]
[TD]Mon[/TD]
[TD]Tue[/TD]
[TD]Wed[/TD]
[TD]Thu[/TD]
[TD]Fri[/TD]
[TD]Sat[/TD]
[TD]Sun[/TD]
[TD]Mon[/TD]
[TD]Tue[/TD]
[TD]Wed[/TD]
[TD]total leave[/TD]
[/TR]
[TR]
[TD]Name 1[/TD]
[TD]A[/TD]
[TD]A[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]A2[/TD]
[TD][/TD]
[TD][/TD]
[TD]S1[/TD]
[TD][/TD]
[TD][/TD]
[TD]TL1[/TD]
[TD]TL2[/TD]
[TD][/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]Name 2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]TL[/TD]
[TD]A[/TD]
[TD]A1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]2.5[/TD]
[/TR]
</tbody>[/TABLE]

In the example above I would like the total leave to be summed from columns B to O and returned in column P, based on the codes entered.

A whole day annual leave. A1 half day annual leave am. A2 half day annual leave pm.
S1 half day sick am. TL time off in lieu. TL1 time off in lieu am. TL2 time off in lieu pm.

The previous formula I posted counts this, however it doesn't count only the half days as a half, it seems to sum all the codes then half the total number.

I'm not sure of the formula is confusing this because of the IF & OR functions that I've used because I have numerous different categories.

Hopefully this makes sense of what I am trying to achieve and any thoughts how to sort this would be appreciated.

Thanks,
EMcK
 
Upvote 0
Maybe something like this


[Table="class: grid"][tr][td="bgcolor: #DCE6F1"][/td][td="bgcolor: #DCE6F1"]
A
[/td][td="bgcolor: #DCE6F1"]
B
[/td][td="bgcolor: #DCE6F1"]
C
[/td][td="bgcolor: #DCE6F1"]
D
[/td][td="bgcolor: #DCE6F1"]
E
[/td][td="bgcolor: #DCE6F1"]
F
[/td][td="bgcolor: #DCE6F1"]
G
[/td][td="bgcolor: #DCE6F1"]
H
[/td][td="bgcolor: #DCE6F1"]
I
[/td][td="bgcolor: #DCE6F1"]
J
[/td][td="bgcolor: #DCE6F1"]
K
[/td][td="bgcolor: #DCE6F1"]
L
[/td][td="bgcolor: #DCE6F1"]
M
[/td][td="bgcolor: #DCE6F1"]
N
[/td][td="bgcolor: #DCE6F1"]
O
[/td][td="bgcolor: #DCE6F1"]
P
[/td][/tr]
[tr][td="bgcolor: #DCE6F1"]
1
[/td][td][/td][td]
1​
[/td][td]
2​
[/td][td]
3​
[/td][td]
4​
[/td][td]
5​
[/td][td]
6​
[/td][td]
7​
[/td][td]
8​
[/td][td]
9​
[/td][td]
10​
[/td][td]
11​
[/td][td]
12​
[/td][td]
13​
[/td][td]
14​
[/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
2
[/td][td][/td][td]
Thu​
[/td][td]
Fri​
[/td][td]
Sat​
[/td][td]
Sun​
[/td][td]
Mon​
[/td][td]
Tue​
[/td][td]
Wed​
[/td][td]
Thu​
[/td][td]
Fri​
[/td][td]
Sat​
[/td][td]
Sun​
[/td][td]
Mon​
[/td][td]
Tue​
[/td][td]
Wed​
[/td][td]
Total leave​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
3
[/td][td]
Name 1​
[/td][td]
A​
[/td][td]
A​
[/td][td][/td][td][/td][td][/td][td]
A2​
[/td][td][/td][td][/td][td]
S1​
[/td][td][/td][td][/td][td]
TL1​
[/td][td]
TL2​
[/td][td][/td][td]
4​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
4
[/td][td]
Name 2​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]
TL​
[/td][td]
A​
[/td][td]
A1​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]
2,5​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
5
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
6
[/td][td]
Code​
[/td][td]
Leave​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
7
[/td][td="bgcolor:#F2F2F2"]
A​
[/td][td="bgcolor:#F2F2F2"]
1​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
8
[/td][td="bgcolor:#F2F2F2"]
A1​
[/td][td="bgcolor:#F2F2F2"]
0,5​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
9
[/td][td="bgcolor:#F2F2F2"]
A2​
[/td][td="bgcolor:#F2F2F2"]
0,5​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
10
[/td][td="bgcolor:#F2F2F2"]
S1​
[/td][td="bgcolor:#F2F2F2"]
0,5​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
11
[/td][td="bgcolor:#F2F2F2"]
TL​
[/td][td="bgcolor:#F2F2F2"]
1​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
12
[/td][td="bgcolor:#F2F2F2"]
TL1​
[/td][td="bgcolor:#F2F2F2"]
0,5​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
13
[/td][td="bgcolor:#F2F2F2"]
TL2​
[/td][td="bgcolor:#F2F2F2"]
0,5​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
14
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


Create a table Code - Leave (gray area)

Formula in P3 copied down
=SUMPRODUCT(SUMIF($A$7:$A$13,B3:O3,$B$7:$B$13))

Hope this helps

M.
 
Upvote 0
Thanks Marcelo, this does exactly what I need and is simpler than what I was trying to do.

thanks again.
EMcK
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top