Text field for filtered results

While creating a dashboard, I created a text field to show count of rows query results. I used markdown {{query.data.field.length}} in text box. Is there any way I can show count of rows corresponding to certain value at component level without making changes to query? I intend to use the same query to create different text fields, each showing count of certain value from query results. Any help will be appreciated.

Hey @khandoba – I'm not entirely sure what you mean here, but I think you might be touching on using JavaScript to filter values from your query based on which particular component you're using? If so, it's going to be some combination of .map and .filter. If you send over more information / screenshots I can help!

I will try to elaborate. I have a text field which shows count of rows of a certain query's result.
Say the query1 is "select * from table1". and text field value is {{query1.data.[id].length}}
Now in this table that is coming from query, I have a column which can have one of the two values. So if I want to show the count of rows matching only one of those values, do I need to write a separate query or can I do it at component level?

@khandoba seems like you'd want to filter the query1.data.[id] array for whatever value you're looking for. E.g. if your employee_type column could have values for Employee or Manager, you'd use something like:

query1.data.employee.filter(item => item === 'Manager')

Can you explain the syntax here more? I am struggling to replicate it as you have it set up. What are you defining as 'item'?

item in his snippet can be named anything, it's just an element of an array (in this case an instance of employee from the array query1.data) that you're passing into the filter method to check against a statement.

What are you trying to filter?