Need SUM of a cell range divided by # WHERE other column MONTH = X

wkmartin

New Member
Joined
May 9, 2018
Messages
3
Although not a newbie I am not an advanced user, but do understand logic and I do some programming.
Having difficulty getting formula to work where desired result is SUM of cell range divided by X WHERE another column entry equals a certain month.
I need the answer to NOT be VBA, script, etc, but an Excel Formula entered into desired cell.

Thinking SQL type logic I would say "SUM of cell range A / # WHERE MONTH of cell range B = 4 (April)
my current formula is:
=SUMPRODUCT(($K$2:$K$196)/N9),IF(MONTH($F$2:$F$196=4))

have also tried:
=IF(MONTH($F$2:$F$196)=4, SUM($K$2:$K$195/N9)

Column F has date in YYYY-MM-DD format and that is working for several other Formulas being used.
Column K has whole number integers from "0" thru "99"
"N9" (or NX if you will) has a valid integer from 1 thru 99

If more info needed Please Ask and I will provide
I could duplicate, reduce and redact the actual spreadsheet but hoping not to have to do so as it would require hours of work.

Thank any and all for assistance.

 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
=SUMPRODUCT(($K$2:$K$196)/N9)*(MONTH($F$2:$F$196)=4))
or if that produces zero try
=SUMPRODUCT(--($K$2:$K$196)/N9)*(MONTH($F$2:$F$196)=4))
 
Upvote 0
=SUMPRODUCT(($K$2:$K$196)/N9)*(MONTH($F$2:$F$196)=4))
or if that produces zero try
=SUMPRODUCT(--($K$2:$K$196)/N9)*(MONTH($F$2:$F$196)=4))

Thank you. The formula gave the wrong answer but that lead me to the issue.
So, your supplied answer is great, the issue is that not all cells in the cell range have a date, some are blank.
Limiting the formula to those having a date entry:
=SUMPRODUCT(($K$2:$K$42)/N9)*(MONTH($F$2:$F$42)=4))
Yields the correct answer.

I know that sometimes having blanks in the array/range causes issues.
For now, rather than spending more time on it I'll populate the blank cells with a date that won't affect my results.

Thank you again, your response is appreciated.
 
Upvote 0
Well, it seemed to work, but further investigation shows that it is not limiting the total to the entries in April (4).
Both formulas return a SUM of ALL entries in K2:K42 / N9, not excluding entries in F2:F42 that are <> 4.

So more investigation needed.
If you have any further ideas or input please advise.
 
Upvote 0
From the original formula
=SUMPRODUCT(($K$2:$K$196)/N9)*(MONTH($F$2:$F$196)=4)*(F2:F196<>0))

Your revised formula looks fine
Note MONTH() does not take into account year so the formula will return both 2018 April and 2017 April
 
Upvote 0

Forum statistics

Threads
1,215,484
Messages
6,125,066
Members
449,206
Latest member
Healthydogs

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