Computing Metrics
Use the optional select clause to compute metrics for your aggregated groups. Use these rules when constructing the select statement:
- Separate metric statements or distinct() function calls by commas.
- If you leave this control empty, IQL returns a count of all documents in each group.
The following metrics are available:
| Metric | Syntax | Examples | 
|---|---|---|
| Simple metric name | metric | revenue | 
| Arithmetic expression of two metrics (+, -, *, %) executed on each document. The divide operation (/) is executed in aggregate after everything else is computed. If you require a per document divide, use a reverse slash (\\). | metric+metric metric\-metric metric\*metric metric%metric metric/metric | clicks/impressionsrevenue-expenses | 
| Function calls: 
 | count() exp(metric,scalingFactor) floatscale(field,scale,offset) | count()floatscale(float,10,5)multiplies each value infloatby 10 and then adds 5 to each product. | 
| distinct() | distinct(field) | distinct(country)returns a count of distinct terms for thecountryfield in each grouping. | 
| percentile() | percentile(field, N) | percentile(totaltime, 50)returns the median value oftotaltime. | 
| Return a count of all of the documents that match the expression. Adding /count()returns the average. You must include""around a string term. | field="term" field=integer metric!=integer metric\<integer metric<=integer metric>integer metric>=integer lucene("luceneQueryStr") | country="us"returns the number of documents with a value ofusforcountry.clicks=1returns the number of documents with a value of1forclicks.revenue>500group="mobile"/count() |