column expression

Hi everybody. i have a question about an error i faced with.
I write this expression and it doesn’t work.
//mean = (round(average(column(“201801”),column(“201802”),column(“201803”)),2)) * 1000
join(mean, “$”)//
the error is:
An error occurred during the execution of the script in function ‘average’ at line 1: The provided element ‘105’ of type ‘String’ is not a valid number.

i changed the type “string” but the same error is showed.

Hi Mitrazz.

if you can, please, show the data that you are working with. The error says that in one/some of the columns (201801, 201802, 201803) you have not a number values (integer of double), but a string (text).

Best regards,
Alex

3 Likes

Hi @Mitrazz,

As @alex_never said you have at least one column of type string. You can convert the column to a numeric type like integer or double by using the String to Number node or simply use the toInt() or toDouble() functions in the Column Expressions node to convert the type of the column(s).

E.g.
mean = round(average(toInt(column("201801")),toInt(column("201802"))),2) * 1000

:blush:

3 Likes

To @Mitrazz.

And after that in join statement don’t forget to use “string(mean)” instead of “mean”, otherwise you will get another error message.

BR,
Alex.

2 Likes

Hi @alex_never,

Not in the Column Expressions node. But yes, in the String Manipulation node, all the arguments of the join() function must be string.

:blush:

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.