--- title: "CopyDiscrete" slug: "copydiscrete" updated: 2022-02-09T19:36:27Z published: 2022-02-09T19:36:27Z canonical: "docs.datajet.app/copydiscrete" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.datajet.app/llms.txt > Use this file to discover all available pages before exploring further. # CopyDiscrete ## 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 | Property | Value | | --- | --- | | **FieldType** | String / Integer / Long(Integer) / Double / Date / DateTime | | **FieldSize** | Low / Med / High / Continuous | | **DataType** | Discrete / Continuous | | **DataSize** | Byte / Short / Integer | The type of field created will be the same as the source field. ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/Gen_CopyDiscrete_Sample.PNG) ## 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. | | **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 ```json { "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 | Example | Details | | --- | --- | | **Description** | **Create a field for high value products** | | **Input** | - Table: = [transactions] - Filter:= [transactions].[price]>500 - **Function: = CopyDiscrete** - Source Field:= product - Name: =High_PriceProducts | | **Sample** | ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/Gen_CopyDiscrete_Example.png) |