- 2 Minutes to read
- Print
- DarkLight
- PDF
DescendingIndex
- 2 Minutes to read
- Print
- DarkLight
- PDF
General: DescendingIndex
Assigns an integer to each unique value in the field, working in reverse order.
Creates an Integer field with values N to 1, where N is the number of discrete values in the source field.
Purpose
- Reverse sort unique values in a field
- Transform a field into an integer for use with integer engineering functions
Return Value
Property | Value |
---|---|
FieldType | Integer / LongInteger |
FieldSize | Low / Med / High |
DataType | Discrete |
DataSize | Byte / Short / Integer |
Example Return Value: N......1
Parameters
Parameter | JSON | Description |
---|---|---|
Table | “targetTable”: “MyTableName” | The target table on which the new field will be created |
Filter | “dataset”: {DataSet_JSON} | Optional. If a filter is applied, records not in the filter recordset will be returned as null. Use a filter to exclude records from the source field. If the source field has too many discrete values to create a DescendingIndex, excluding some records may reduce the index size enough for a discrete index to be created. To specify records to Exclude:
|
Function | "function":"descendingindex" | DescendingIndex |
Source Field | “p1”: “SourceFieldName” | Required. The Discrete (i.e., non-continuous) field from which to create the index. If it is necessary to create an index from a continuous field, depending on the field contents, the CONCAT function can sometimes be used to create a discrete copy of the continuous field. If the continuous field is a numeric field, the output from the CONCAT function can be cast back into a numeric field using the WILDICAST function. Strings can be cast as date fields using the DateFromString function. |
Treat Null as Zero | "nullIsZero": true "nullIsZero": false | True/False. Default = False If true, then any null values in the input fields will be treated as if they have a value of 0. |
JSON Sample
{
"method": "BuildBakedField",
"project": "D3",
"targetTable": "transactions",
"overwrite": true,
"name": "DescIndex_date",
"function": "descendingindex",
"p1": "date"
}
Usage Notes
The function only works on Discrete source fields. See CONCAT, WILDICAST and DATEFROMSTRING if it is necessary to create an index from a Continuous field.
If a filter is applied, records which are not in the filter will be stored as NULL in the new field. Applying a filter may reduce the number of discrete values in a continuous field sufficiently to create a discrete index.
The maximum number of discrete values in a discrete index is 1,000,000
For more information on field and data types, see Field Types and Data Types
See Also:
- Engineering | Expression Field
- CONCAT (String Function)
- WILDICAST (String Function)
- DATEFROMSTRING (String Function)
Example
Example | Details |
---|---|
Description | Create a descending index from average spend |
Input |
|
Sample |