This article will cover the syntax of the ‘drop field’ regular script statement.
The drop field statement allows you to delete a field from a previously loaded table that’s part of the data model. Note that it does not delete the field from the original data source.
Statement syntax
Drop fields | field fieldname { , fieldname2 ...}
From tablename { , tablename2 ...}
Fields | Field | You can specify to drop a single or multiple fields. Note that even if you use the single ‘field’ syntax you can still specify multiple field names to be dropped. It therefore makes no difference which syntax you use. |
Fieldname | A comma separated list of field names to be dropped. |
Tablename | A comma separated list of tables from which the fields must be dropped. Note that specifying the table is optional if you want to drop all occurrences of a field. |
Example
In this example, we load a table and create a new field by concatenating two fields together. The original two fields are then dropped from the data model.
ITEM_DETAILS:
LOAD
"id",
"cost",
"type",
"flavour",
"type"&' : '&flavour as "typeFlavour"
FROM [lib://Public:DataFiles/ITEM_DETAILS.qvd] (qvd);
Drop fields "type", "flavour";
Result
The result is a table containing fields: “id”, “cost” and “typeFlavour” only.