Learn about summing by group, and find out what other calculations are possible with reduceSum().
- [Instructor] Reduced sum lets you use values…from your data to calculate an output.…You can see on the dashboard that we have total spend…here twice and both of these have been calculated…by reduced sum, but reduced sum allows you…to do a lot more than summing.…You can average or perform other calculations,…anything that requires you to access values…from your data, rather than a row count.…So let's check how to generate this number.…We can say, facts.groupAll.reducedSum…and reduced sum always takes the function…because it needs a bit of a clue where to look for the data.…
So here we'll say, return d.total, like so.…If we check that, we've got the 1720…that is shown on the dashboard.…Now, how about summing one field, but grouping by another?…For this we'll use print_filter and we can say,…typeGroup.reduceSum.…
Now we have, instead of a row count, we have the total spend…split but type, but instead of type we've got A and I…because we're still deciding type group as D.string.…So we can just get rid of, in fact, that whole function…
Released
1/9/2017- Downloading Crossfilter
- Cross-filtering data
- Creating dimensions
- Grouping data
- Filtering by range and function
- Removing matching records
Share this video
Embed this video
Video: Calculating from data points with reduceSum()