Carrot reference
Methods
methods methods are special types of functions docid\ izsyklqfbetmslmltbmay that apply to a list docid\ xwh cukhj9waqaefb7h71 or sequence of data usually, methods are used to aggregate data – such as counting or summing list values syntax methods are called like this, where subject is the subject of the method, such as the list or sequence that is being aggregated subject methodname(parameter1, parameter2) if the method is passed an expression as a parameter, you can use either of the following syntaxes they both mean the same thing subject methodname({expression}) subject methodname{expression} the second is often preferred, for clarity and brevity methods can be chained together to form a pipeline of evaluations for example subject methodname1{expression1} methodname2{expression2} example usages methods can be used anywhere in carrot most commonly, methods will operate on a list – for example, to calculate the total number of shares from the grants docid\ lpx5l8w1t54ipbqq8eqjv field, only counting grants that have a strike price of less than 10 cents, one could write grants filter{price < 1} sum{shares} method list method description all() returns true if all of the items match an expression any() returns true if at least one of the items matches an expression ` count() returns the number of items matching an expression ` filter() returns a list of items that match an expression find() docid 6mwj2hjz9ljkhmbfk0vvo when called against a table, queries for entities in that table matching the expression ` groupby() generally only used in dashboards groups the items by key, returning a sequencegroupedby, that can be aggregated ` join() returns a string that joins the items together ` limit() returns a list of items, with the number of the items limited to a certain number ` map() returns a list of items that have been transformed using the mapping expression passed in ` max() returns the maximum value of the items in the list, excluding nulls ` mean() returns the arithmetic mean (average) of the items in the list, excluding nulls ` min() returns the minimum value of the items in the list, excluding null ` none() returns true if none of the items matches an expression ` sort() returns a list of items, sorted by an expression ` sortdesc() returns a list of items, sorted in descending order sum() returns the sum of the items (optionally transformed with an expression) unique() docid\ oyypykrfy06brsvjbfeti returns a list filtered down to its unique items aggregators (deprecated) aggregators are special expressions used to aggregate values over time, only used in charthop dashboards however, aggregators are now deprecated we recommend that you replace their use with the corresponding charthop methods above the dashboards ui will be migrated to use methods instead syntax an aggregator in carrot appears as a word followed by curly brackets, which contain an expression aggregator{expression} an aggregator performs a calculation on the parameter expression and returns a number https //docs charthop com/uci5 number value based on the aggregator's logic all aggregators are case insensitive usage aggregators are only available in dashboards migration to replace the use of an aggregator currently used in a dashboard with a method call instead, use the following syntax db job find(jobfilter) aggregator{expression} for example, this aggregator call count{headcount if department\ engineering} becomes db job find{department\ engineering} count{headcount} aggregator list aggregator description count{} counts the number of times a given expression evaluates to a truthy value all non truthy values, such as null , an empty string, 0 , or false are discarded max{} returns the largest value of a given expression all non numeric values are discarded mean{} returns the average of all values of a given expression all non numeric values are discarded min{} returns the smallest value of a given expression all non numeric values are discarded sum{} returns the sum of all values of a given expression all non numeric values are discarded