nikooters
nikooters

Reputation: 311

Faulty COUNTIFS() Function Excel

UPDATE: I ran a script which re-enabled automatic calculation, enabled the screen updating and all the other good stuff and the functions now work. I'm moving forward with the impression it was yet another Excel visual glitch and the functions were working, just the screen was somehow breaking these cells. Thank you everyone for your rapid responses and support, I was loosing it.


Initial Issue:

This has been driving me crazy. I built a function with COUNTIFS() in Excel, which finds the number of times in a column, this work week is listed, when the model number matches. The models are 6.3, 6.4, and 6.5. For models 6.3 and 6.4, the function work and does all the calculation correctly. For the 6.5, even if the function is exactly the same, it does not. In fact, when I evaluate the function, I get the right math as a result (it should be 3-2 = 1), yet it ends up as 0:

Evaluated Function before last step

Evaluated Function after last step

I can't give too many details of the functions due to proprietary information disclosure. However, I can show you what data it is reading with every other column and row hidden, so I apologize if it looks messy, the only two arrays in the COUNTIFS() functions (top bright red and green boxes, with associated model number underlined above) are matching the model number to the far left column (in yellow, red and light green), and today (1921) work week and year to the second to the left column (in dark and light green):

Red is what I'm subtracting from the sum of the rest in Yellow and Green

I can show you the functions do work, when I switch the first row's model from a 6.3 to a 6.4, the appropriate change for 6.3 switches from a count of 1 to a count of 0, and that of the model 6.4 changes from a count of 5 to a count of 6:

Changing the model number from the drop-down Now the values up-top correctly update

However, when I switch the first row's model to a 6.5, both the 6.3 and the 6.4 COUNTIFS() correctly update (0 and 5 consecutively), but not the 6.5 (still 0, should show 2 now):

Switched from 6.3 to 6.5

Just to prove to you, I run "Evaluate Formula" on the cell, and the result is correct (4-2), yet the last step it craps out and shows 0:

Last step of Evaluation is correct Before it craps out at the last step and shows 0

A simplified version of the function is:

=COUNTIFS(ModelArray,ModelNumber,WorkWeekArray,INDEX(WorkWeekArray,MATCH((NUMBERVALUE(RIGHT(YEAR(NOW()),2)&TEXT((WEEKNUM(NOW(),21)),"00"))),WorkWeekArray,0)))- COUNTIFS(ModelArray,ModelNumber,ModelStatus,StatusIsRed,WorkWeekArray,INDEX(WorkWeekArray,MATCH((NUMBERVALUE(RIGHT(YEAR(NOW()),2)&TEXT((WEEKNUM(NOW(),21)),"00"))),WorkWeekArray,0)))

Each WorkWeekArray value listed is also computed using the same NUMBERVALUE() Function:

NUMBERVALUE(RIGHT(YEAR(ModelDate),2)&TEXT((WEEKNUM(ModelDate,21)),"00")

Please help, I'm loosing my mind and this is a critical tool I'm building. It makes me look bad when the software isn't functioning as it should! Thank you in advance :)


Appendix for Comments:

Named Ranges in the Workbook

Upvotes: 1

Views: 194

Answers (1)

Tyler M
Tyler M

Reputation: 422

Wish I could comment because this isn't really a good answer. I'll keep editing it as I come up with more suggestions. Try this:

  • Make sure there are no strange lingering characters in your data. Such as a hidden space " " tagged on to the end of your data. I especially think it may be something along these lines, and that one of your data points may being treated as a 'string' instead of a 'number', because the image you posted of "3-2" it looks like the "2" is italicized but the "3" is not.
  • If you can step through the data cell-by-cell, try using F9 to evaluate the formulae's results. This tutorial explains how to use F9 to debug your formulas. Make sure there's not a strange occurrence somewhere upstream of this final calculation.
  • It probably has more to do with the data than it does with the formula you linked, because you said yourself the formula works for 2 of your 3 use cases.

Upvotes: 1

Related Questions