Aug 05 2020 07:51 AM
Hello!
I'm currently completing a business information systems unit and I've encountered an issue where the task requires me to use a CountIF formula drawing details from a Milk Products table (I7:Q18) and adjusting it with a ratio from the Milk production table (I28:N39). I would like the ability to be able to sort the Milk Products table, but my formula currently addresses fixed cell variables, and when I sort that table, the results understandably change.
The primary requirement for this particular column M31:38 requires the use of a CountIf formula, but I can't figure out what to pair with it to have it survive a re-sort of I7:Q18.
I've attached the spreadsheet for ease of reference.
Any help would be greatly appreciated!
TIA,
Paul
Aug 05 2020 08:00 AM
SolutionThat could be
=COUNTIF($I$9:$I$16,I31)*
INDEX($K$9:$K$16,MATCH($I31,$I$9:$I$16,0))*
INDEX($L$9:$L$16,MATCH($I31,$I$9:$I$16,0))*
INDEX($N$9:$N$16,MATCH($I31,$I$9:$I$16,0))*
K31
Aug 05 2020 08:33 AM
Wow. That's incredibly impressive and simpler than I was trying to make it. Thanks so much Sergei, I've been throwing my head at this for a week now trying to make it work! Am I right in reading this formula that its sorting the calculations for this by indexing against each of the columns which are filtered, matching it against the product code criteria in milk production, lining it up with the equivalent criteria in milk products, and then selecting the exact match based on that information?
Just want to make sure I understand how its working, instead of copying it and calling it a day.
Thanks SO much for your time, you've just cured a very big perpetual headache.
Kind Regards,
Paul
Aug 05 2020 09:23 AM
Paul, you are welcome.
Yes, MATCH finds the current row number for the product code in "Milk Products" table, and INDEX takes value from another column for the found row.
Aug 05 2020 08:00 AM
SolutionThat could be
=COUNTIF($I$9:$I$16,I31)*
INDEX($K$9:$K$16,MATCH($I31,$I$9:$I$16,0))*
INDEX($L$9:$L$16,MATCH($I31,$I$9:$I$16,0))*
INDEX($N$9:$N$16,MATCH($I31,$I$9:$I$16,0))*
K31