I have a long (approx. 4000 rows) list whose elements are in the form as follows:


I want to count the number of elements c in the last column that are greater than a certain number d. How can I do it?

  • 3
    $\begingroup$ Total@UnitStep[data[[All, -1]] - d]? Of course, Count is much nicer to read, but also much slower. To have something nice to read and fast, check out BoolEval (BoolCount) $\endgroup$
    – Szabolcs
    Sep 21, 2018 at 14:29
  • $\begingroup$ The direct route: Count[ data, { __, c_ /; c > d}] $\endgroup$
    – Jason B.
    Sep 21, 2018 at 14:32
  • $\begingroup$ Cannot understand what the structure of your list is. $\endgroup$ Sep 21, 2018 at 14:42
  • $\begingroup$ @ΑλέξανδροςΖεγγ It contains a list and three numbers for each row. $\endgroup$
    – mattiav27
    Sep 21, 2018 at 14:54

1 Answer 1


Suppose your long list is named data, one approach can be

Select[data, Last[#] > d &] // Length

where d should have a preset value.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.