Counting how many row in a table are a certain value

Is there a way as described in the subject to do this?
I was thinking something like this but it doesnt work:

len({../Table.props.data}, 'empy_buggy_capacity' >= 81)

Is empy_buggy_capacity a column name in your dataset? In this scenario, I would probably pass in an optional filter field into the query (or however you're coming up with the dataset) and filter it there. This is especially true if you want to filter on numeric data, greater / less than, or a range of data.

With my Integration Toolkit:

len(
	where(
		{../Table.props.data},
		it()['empy_buggy_capacity'] >= 81
	)
)

Not possible in an expression without my toolkit (unless you use runScript()).

3 Likes

If the data doesn't come from a query, and you can't use Phil's integration toolkit:

Add a custom property on the table. I'll call it 'total' because I don't know your system, but find a more explicit name.
Add a property binding to that prop, bind it to this.props.data.
Then add a script transform:
If the table's data is in json format:

return sum(1 for v in value if v['empy_buggy_capacity'] >= 81)

If it's in dataset format:

return sum(1 for v in value.getColumnAsList(value.getColumnIndex('empy_buggy_capacity')) if v >= 81)

thanks alot sir