Mode - script function
Mode() returns the most commonly-occurring value, the mode value, of the aggregated data in the expression, as defined by a group by clause. The Mode() function can return numeric values as well as text values.
Syntax:
Return data type: dual
Argument | Description |
---|---|
expr | The expression or field containing the data to be measured. |
Limitations:
If more than one value is equally commonly occurring, NULL is returned.
Examples and results:
Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in our document to see the result.
Temp:
LOAD * inline [
Customer|Product|OrderNumber|UnitSales|CustomerID
Astrida|AA|1|10|1
Astrida|AA|7|18|1
Astrida|BB|4|9|1
Astrida|CC|6|2|1
Betacab|AA|5|4|2
Betacab|BB|2|5|2
Betacab|DD
Canutility|DD|3|8
Canutility|CC
] (delimiter is '|');
Mode:
LOAD Customer, Mode(Product) as MyMostOftenSoldProduct Resident Temp Group By Customer;
Result field (Customer) | Result value (MyMostOftenSoldProduct) |
---|---|
Astrida | AA |
Betacab | - |
Canutility | - |