Deletes a set of rows in your dataset, based on a condition specified in the row
expression. If the conditional expression is true
, then the row is deleted. The delete
transform is the opposite of the keep
transform. See Keep Transform.
Basic Usage
delete row:(dateAge >= 90)
Output: For each row in the dataset, if the value in the dateAge
column is greater than or equal to 90
, the row is deleted.
Syntax and Parameters
delete row:(expression)
Token | Required? | Data Type | Description |
---|---|---|---|
delete | Y | transform | Name of the transform |
row | Y | string | Expression identifying the row or rows to delete. If expression evaluates to true for a row, the row is removed. |
For more information on syntax standards, see Language Documentation Syntax Notes.
row
true
or false
.Examples:
Expression | Description |
---|---|
Score >= 50 | true if the value in the Score column is greater than 50. |
LEN(LastName) > 8 | true if the length of the value in the LastName column is greater than 8. |
ISMISSING([Title]) | true if the row value in the Title column is missing. |
ISMISMATCHED(Score,['Integer']) | true if the row value in the Score column is mismatched against the Integer data type. |
Example:
delete row: (lastContactDate < 01/01/2010 || status == 'Inactive')
Output: Deletes any row in the dataset where the lastContactDate
is before January 1, 2010 or the status is Inactive
.
Usage Notes:
Required? | Data Type |
---|---|
Yes | Expression that evaluates to true or false |
Tip: For additional examples, see Common Tasks.
Examples
Example - Remove old products and keep new orders
delete
- Deletes a set of rows as evaluated by the conditional expression in therow
parameter. See Delete Transform.keep
- Retains a set of rows as evaluated by the conditional expression in therow
parameter. All other rows are deleted from the dataset. See Keep Transform.
Source:
Your dataset includes the following order information. You want to edit your dataset so that:
- All orders for products that are no longer available are removed. These include the following product IDs:
P100
,P101
,P102
,P103
. - All orders that were placed within the last 90 days are retained.
OrderId | OrderDate | ProdId | ProductName | ProductColor | Qty | OrderValue |
---|---|---|---|---|---|---|
1001 | 6/14/2015 | P100 | Hat | Brown | 1 | 90 |
1002 | 1/15/2016 | P101 | Hat | Black | 2 | 180 |
1003 | 11/11/2015 | P103 | Sweater | Black | 3 | 255 |
1004 | 8/6/2015 | P105 | Cardigan | Red | 4 | 320 |
1005 | 7/29/2015 | P103 | Sweeter | Black | 5 | 375 |
1006 | 12/1/2015 | P102 | Pants | White | 6 | 420 |
1007 | 12/28/2015 | P107 | T-shirt | White | 7 | 390 |
1008 | 1/15/2016 | P105 | Cardigan | Red | 8 | 420 |
1009 | 1/31/2016 | P108 | Coat | Navy | 9 | 495 |
Transform:
First, you remove the orders for old products. Since the set of products is relatively small, you can start first by adding the following:
NOTE: Just preview this transform. Do not add it to your recipe yet.
delete row:(ProdId == 'P100')
ProdId
value. If you look at the ProductName
value, you might notice that there is a misspelling in one of the affected rows, so that column is not a good one for comparison purposes. You can add the other product IDs to the transform in the following expansion of the transform, in which any row that has a matching ProdId
value is removed:
delete row:(ProdId == 'P100' || ProdId == 'P101' || ProdId == 'P102' || ProdId == 'P103')
OrderId | OrderDate | ProdId | ProductName | ProductColor | Qty | OrderValue |
---|---|---|---|---|---|---|
1004 | 8/6/2015 | P105 | Cardigan | Red | 4 | 320 |
1007 | 12/28/2015 | P107 | T-shirt | White | 7 | 390 |
1008 | 1/15/2016 | P105 | Cardigan | Red | 8 | 420 |
1009 | 1/31/2016 | P108 | Coat | Navy | 9 | 495 |
Now, you can filter out of the dataset orders that are older than 90 days. First, add a column with today's date:
derive value:'2/25/16' as:'today'
keep row:DATEDIF(OrderDate,today,day) <= 90
today
column, which is no longer needed:
drop col:today
OrderId | OrderDate | ProdId | ProductName | ProductColor | Qty | OrderValue |
---|---|---|---|---|---|---|
1007 | 12/28/2015 | P107 | T-shirt | White | 7 | 390 |
1008 | 1/15/2016 | P105 | Cardigan | Red | 8 | 420 |
1009 | 1/31/2016 | P108 | Coat | Navy | 9 | 495 |
This page has no comments.