Hi All,
I need to replace zero with next value in array.
ex: {1,2,3,0,0,10,15,0,14,0} ; then result should be {1,2,3,10,10,10,15,14,14,0}
Thanks
Discussion posts and replies are publicly visible
a!localVariables( local!values: {1,2,3,0,0,10,15,0,14,0}, a!forEach( items: local!values, expression: if( fv!item = 0, index( /* Only take values after the current one */ ldrop(local!values, fv!index - 1), /* Find the first not being zero */ /* where() evaluates zero as false and >0 as true */ index(where(ldrop(local!values, fv!index - 1)), 1, 0), fv!item ), fv!item ) ) )
This should do it. May I ask what the use case is?
Thank you Stefan!
This is a part of business requirement where we need to replace 0 with next amount value.