Can't work with array methods when try define 'Primary value' in 'statistic' component

Hello.
I have some problem when try to make statistic and define Primary value. I can't work with array methods as described in the documentation Array methods

For my example I used Learn with an example app in the main part Welcome to Retool page and fixed Avg seat cost statistic component.
I want to filter all values with simple validation. For example
This query works fine:

{{formatDataAsArray(activeCustomers.data).length}}

But this query doesn't work.

{{formatDataAsArray(activeCustomers.data).filter(row=>)}}

Tell me, please, why in the Primary value don't work codes like:

{{formatDataAsArray(activeCustomers.data).filter(row=>)}}

or

let data = {{formatDataAsArray(activeCustomers.data)}}
let filtered = data.filter(row=>parseFloat(row.roomid)!=parseInt("3"))

return filtered

What should I use to solve this problem?

Hey @Maksym!

It looks like your transformer is returning an array, that would also make sense with the error you're seeing since an array has the 'object' type: The value has to be of type 'number', you provided a value of type 'object'

Can you try returning filtered[0] instead of filtered and let me know if that works?

I made request:
{{formatDataAsArray(activeCustomers.data).filter[0](row=>parseFloat(row.avg_cost_per_seat)!=parseInt(3))}}
And got warning:
formatDataAsArray(...).filter[0] is not a function

and tried with filtered
request:
{{formatDataAsArray(activeCustomers.data).filtered[0](row=>parseFloat(row.avg_cost_per_seat)!=parseInt(3))}}
warning:
Cannot read properties of undefined (reading '0')

Got it, can you try doing either

let data = {{formatDataAsArray(activeCustomers.data)}}
let filtered = data.filter(row=>parseFloat(row.roomid)!=parseInt("3"))

return filtered[0]

or

{{formatDataAsArray(activeCustomers.data).filter(row=>parseFloat(row.avg_cost_per_seat)!=parseInt(3))[0]}}

The entire expression data.filter(row=>parseFloat(row.roomid)!=parseInt("3")) should equal an array, same with formatDataAsArray(activeCustomers.data).filter(row=>parseFloat(row.avg_cost_per_seat)!=parseInt(3)). So whether you store it in a variable first or try accessing the index right away the call to the index should come at the end.