there are several ways to do this, the easiest is to precalculate with firstsortedvalue.
Remember: everything you do in the front-end is calculated at runtime. It is therefore advised to do the calculation in the Qlik script.
May be try this
291337.qvf 176.0 K