One things that can cause an issue here is if some of your columns have lower case versus upper case.
Can you actually just use COUNTROWS( tablename) as your formula. That’s all you need to check this. (I do this quite often and have had this happen occassionally)
Also double check that you are in fact checking this with a table at the highest level of granularity. Is the table definitely at the level of context?
Another tip. In the query editor, maybe test this and filter the table for only one of these stockcodes. That will make auditing this way easier. If you find the issue for one, you’ll find the general problem. I find this all the time.