Calc ignoring hidden rows when appling increment

Hi is there a way to apply a simple increment to a column and have the increment ignore hidden rows in the calculation?

The Aggregate function can ignore hidden rows.
For example, enter the formula in cell A1

=AGGREGATE(2;5;$A$1:$A1)

and drag down.
Now try hiding/showing rows.

Thanks sokol. Had a read on aggregate and got it working. Much appreciated :+1: