crossfilter / reductio

Reductio: Crossfilter grouping
Other
250 stars 42 forks source link

Count Distinct #29

Closed nordfjord closed 8 years ago

nordfjord commented 8 years ago

Is there a way to count distinct values currently?

I have a creeping suspicion I will be needing to do some cardinality dimensions and having them as reducers would be awesome

var group = reductio()
  .countDistinct(d => d.order_number)
  (group);

would have

[{
  "key": "dimension1",
  "value": {
    "countDistinct": 4
  }
}, {
  "key": "dimension2",
  "value": {
    "countDistinct": 2
  }
}]
nordfjord commented 8 years ago

I will get on implementing this if there's no way to achieve this currently

esjewett commented 8 years ago

Exception aggregation is badly named, but is designed to handle this use-case: https://github.com/esjewett/reductio#aggregations-standard-aggregations-exception-aggregation

nordfjord commented 8 years ago

Awesome :+1:

esjewett commented 8 years ago

If you have any suggestions for naming it better, I'm all ears. I was thinking "unique" or "uniqueBy" - https://github.com/esjewett/reductio/blob/master/NOTES.md

nordfjord commented 8 years ago

I would've chosen "distinct", but that is mainly because it's standard SQL.

SELECT DISTINCT CustomerName
FROM Customers

in SQL unique is used in the create table statement to indicate a field contains unique values.

Fil commented 8 years ago

agree with distinct (at least this is how I landed on this page: searching for "reductio count distinct") :-)