CopyDiscrete
  • 1 Minute to read
  • Dark
    Light
  • PDF

CopyDiscrete

  • Dark
    Light
  • PDF

Article summary

General: CopyDiscrete

Makes a copy of the discrete source field.

The function will not work if used with a continuous DataType.  

It works with all FieldTypes. 

Purpose

Use this function to:
  • Remove unwanted values from a discrete field (by applying a filter)
  • Reduce the number of discrete values for a multi-dimensional analysis (by applying a filter)
  • Create a copy of a field with a more user friendly name

Return Value

PropertyValue
FieldTypeString  / Integer / Long(Integer) / Double / Date / DateTime
FieldSizeLow / Med / High / Continuous
DataTypeDiscrete / Continuous
DataSizeByte / Short / Integer 

The type of field created will be the same as the source field.


Parameters

ParameterJSONDescription
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.
Function"function":"copydiscrete"CopyDiscrete
Source Field“p1”: “NameOfFieldToCopy ”The Discrete (i.e., non-continuous) field to copy.

If it is necessary to copy 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.

JSON Sample

{
  "method": "BuildBakedField",
  "project": "D3",
  "targetTable": "transactions",
  "overwrite": true,
  "name": "copy_day",
  "function": "copydiscrete",
  "p1": "day"
}

Usage Notes

CopyDiscrete is useful for creating fields which contain subsets of values from the original field, or to create copies of fields which have user-friendly names.  

The function only works on Discrete source fields.    See CONCAT, WILDICAST and DATEFROMSTRING if it is necessary to create copies of Continuous fields. 

If a filter is applied, records which are not in the filter will be stored as NULL in copy.

See Also:   

  • Engineering | Expression Field
  • CONCAT   (String Function)
  • WILDICAST  (String Function)
  • DATEFROMSTRING  (DateTime)

Example

ExampleDetails
DescriptionCreate a field for high value products
Input
  • Table: = [transactions]
  • Filter:= [transactions].[price]>500
  • Function: = CopyDiscrete
  • Source Field:= product
  • Name: =High_PriceProducts
Sample





Was this article helpful?