getFormula
A Formula model is a data model that represents a single numerical statistic, such as an average or a count. Suitable for headline or scorecard type of visualizations.
Usage
const formula = await data.widgetSource.getFormula({
column: 'column_name',
operation: 'count',
// + operationExp for custom operations
// + base options...
});Options
The getFormula model inherits all options from the base options, plus:
export interface FormulaRequestOptions extends BaseRequestOptions {
column: string | '*' | '';
operation: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom' ;
operationExp?: string;
}column: the name of the column that you will run the statistical operation on. It also accepts the
*value, that willname of the column
*for total row count , used with count in operationempty string, in combination with custom + operationExp
operation: the statistical operation that will be performed on the column. Accepted values are:
countavgminmaxsumcustom: a custom SQL expression, specified byoperationExp.
operationExp (optional): when using
operation: 'custom'you need to specify the exact SQL operation that you want to run on your column. For example:AVG(column_A) / AVG(column_B) * 100.
Response
A simple object containing the numerical value of the widget:
type FormulaResponse = {value: number};
/* example response
{value: 1433230}
*/The response can be then mapped to any HTML element, such as a scorecard.

Last updated
Was this helpful?
