Stack and sort a vector up to calculated z value
Hi All,
What is the formula to stack the zcal into a vector and rearrange the vector up to the zcal value. Can anyone please advice?

Hi All,
What is the formula to stack the zcal into a vector and rearrange the vector up to the zcal value. Can anyone please advice?

Why didn't you attach your worksheet?
Try

This approach will fail if no value in z.soil is larger than z.cal.
If this is a problem, you may use tray and catch to cope with it

Remarks
Now this approach would give a wrong result if ALL values in z.soil are larger than z.cal.
If z.cal is equal to a value in z.soil, this value will be seen twice at the end of the resulting vector - not sure if this is desired behaviour.
If the values in z.soil are not sorted, you should use sort(trim(....)).
Here is a version which also considers these points. I formulated it as function of z.cal because this makes testing all possible cases easier

Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.