How to count number of rows with multiple specific values in multiple column?
How to count number of rows with multiple specific values in multiple column?

I want to retrieve the num of rows that having "value5" in column5. Also I want to use regular expression for the values.
I tried the following code, it does not work.
var row_count_agency = dt.column(':contains(column5)').rows(':contains("value5")').data().length;
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I find out filter function, but I could not figure out how to filter column1 with value1 and column2 with value2?
var row_count_agency = dt.column( 5 ).data().filter( function ( value, index ) { return value == "value1" ? true : false;} ).length
Hi @langdeyouhuo ,
You can use
filter()
for that - see here,Cheers,
Colin
Thanks @Colin !
But I want to filter with two conditons: column1 with value1 and column2 with value2.
The example you showed to me is only filtering 1 column with specific value.
Is it able to filter column1 with value and then filter column2 with value2, then I want to get the final result.
Best Regards
langdeyouhuo
Hi @langdeyouhuo ,
Yep, you'll need to scan through the rows for that, something like this,
Cheers,
Colin
Thanks @colin !