How to use data().unique().count() but not include null values?

How to use data().unique().count() but not include null values?

mmarzsmmarzs Posts: 12Questions: 4Answers: 0
edited July 2021 in General

I am trying to get the unique count of the filtered table columns (from after a search builder filter is applied), but do not want to include in the count where value is null.

This gets the unique count, but adds in 1 for if there any null value.
var box2SmallCount = table.column( 'unique-engaged-user:name', {filter:'applied'}).data().unique().count()

For reference: here is what is being return getting the column data().unique()

var box2SmallCount = table.column( 'unique-engaged-user:name', {filter:'applied'}).data().unique()

What would be the best way to not count the null value?

Answers

  • mmarzsmmarzs Posts: 12Questions: 4Answers: 0

    nevermind! Of course I figured it out moments after..

    ``` var box2SmallCount = table.column( 'unique-engaged-user:name', {filter:'applied'}).data().unique().filter( function ( value, index ) {
    return value > 0 ? true : false;
    } ).count();``

Sign In or Register to comment.