Open esjewett opened 9 years ago
I'm not an active user... yet... but indeed this name trips me up when I read about reductio. The association with the programming construct is strong for me.
The documentation states:
For our purposes, this means only aggregating once for each unique value that the exception accessor returns.
Are there other purposes, i.e. can "exception aggregation" also do other things besides act on unique values?
I'll just do a mental substitution for now. :-)
It also seems like this operation might be dangerous if the reduction value is not always the same for the exception/unique key.
Yeah, I think it's originally an SAP datawarehousing term. Probably came from German. The idea of exception aggregation is more than just counting unique values, but it's similar. It pretty much means that you define a key (or compound key) secondary to the current displayed dimensions, and you define an aggregation on that key. So say we are viewing revenue by country in our report. But in addition to revenue we also want to display the number of unique products that account for the revenue in each country:
var dimension = crossfilter.dimension(function(d) { return d.country; });
var group = dimension.group(reductio().exception(function(d) { return d.product; }).exceptionCount(true));
Note that it's OK if a product appears in more than one country. It counts against each country, but it only counts at most once for each country.
Ok, but what if we don't just want to count? We want to display the value of the most recent transaction in each country? Then our exception aggregation key would be Date rather than product, and our aggregation strategy would no longer be "just take one" (i.e, unique), but would rather be, take the one with the highest value of Date.
I'm not sure this kind of flexibility is really necessary, but I could certainly see it being useful.
Anyway, yes, renaming to unique
or uniqueBy
would make a lot of sense, at least until I have a more complete approach to the whole problem.
similar discussion in #29
Cool - thanks for the feedback. I think I'm leaning in this direction as well (distinct
, that is). A bunch of updates to Reductio I want make including reworking the API structure, but no time at the moment :-/ If anyone wants to send a pull request to alias this to distinct and add to the documentation, I'd be game.
Might be a little more clear regarding what it does.