You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use the nth_value function with a nth parameter coming from an another column (see the example below).
But it fails. I don't really know if it's the expected behavior or if there's something wrong?
Thanks for posting. Yes, currently nth has to be an externally provided value, such as a constant or parameter. I will mark this as a feature request to enable column values as arguments as well.
jheer
changed the title
Error when using nth_value with nth defined in an another column
Allow nth_value to take a column as the 'nth' argument
Oct 8, 2024
In the meantime, I finally tried to add my first custom function.
Seems to work but I still have to do dig a little more...
aq.addWindowFunction("my_nth_value",{create: ()=>({init: ()=>{},// No initialization neededvalue: (window,columns)=>{letvalue1=window.value(window.index,columns)[1];value1=+value1;if(!(value1>=0))throwError("nth_value nth must be equal or greater than zero.");consti=window.i0+value1;returni<window.i1 ? window.value(i,columns)[0] : null;}}),param: [2]// 2 field inputs, 0 extra parameters},{override: true});
I would like to use the
nth_value
function with anth
parameter coming from an another column (see the example below).But it fails. I don't really know if it's the expected behavior or if there's something wrong?
gives an error
RuntimeError: data is not defined
nth
always has to be a constant?The text was updated successfully, but these errors were encountered: