Index Aggregate formula. Need expert help.

I hope someone can help me out with this…
The formula (listed below)works great in Excel but in Calc I get $Div/0! Errors. I think the problem is with the “aggregate” portion.

Here is the formula:


A shortened version of the spreadsheet is attached for download.

The picture illustrates what I’m trying to accomplish. I need to be able to change the value in AI3 (currently “3”) and have the list update accordingly. Open in Excel and it works great. Open in Calc and I get errors. I need this for work and I only have Calc available there. Any help is very much appreciated!