Learn how to filter by function, including filtering for noncontinuous ranges and filtering for dates.
- [Instructor] For any kind of advanced filtering,…we use a function.…What if we want to return all rows with a tip…greater than zero?…We've already got a tipDimension up here,…so let's get rid of that filter and say,…tipDimension.filterFunction,…and then we write our accessor function,…function(d)…and we say return d greater than zero.…
And there we have the four rows where tip is not zero.…Now something might strike you as a bit peculiar about that.…Where we have used an accessor function like this before,…d has returned us the whole object,…and we've had to say d.tip or d.something…to get a value out of it, but not here.…With filterFunction, if we just log d to the console,…you can see that the only thing that's being passed in…is the tip value itself, so always a good idea…when you're dealing with these accessor functions,…to begin by logging the data point to the console…and see what you've got to work with.…
Now this function will consider the row a match…if the condition holds true.…So the function will run 12 times overall,…
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: Filtering by function