The "Delete rows selectively" instruction can be used to delete rows from a data range, depending on a value(s) located in a specified column(s).
This instruction can be perfect to clean up raw data. For example, consider the following raw and "uncleaned" data, where Sales Amount is expected to always be positive.
There are negative Sales Amounts in the dataset and we wish to delete these records.
Steps
1. Create a data step and upload the data.
2. Create an action step to manipulate data.
3. Select the "Delete rows selectively" instruction.
4. Configure the source range to select the dataset.
5. Select the conditions on which a row will be deleted.
6. Save and run the step.
Once this step completes successfully, the appropriate rows will have been deleted.
This dataset now no longer contains records containing negative Sales Amounts.
Useful tips and resources
The conditions in step 5 can be generalised into more than an "equals to" operator. For example, we can use a wide range of various operators including the below options.
Sometimes, the conditional value may not be fixed and can vary depending on a property elsewhere in the process. And so, instead of writing a literal value in the textbox, we can also link the value to this other property that contains a variable value by choosing "Link" instead of "Literal".
When specifying a condition, the text can be toggled depending on whether case-sensitivity is desired, using the tick-box underneath.
Multiple conditions
Also, we can specify more than one condition to be met consecutively, in order for a row to be deleted.
We can do this by clicking on "Add" and specifying the new condition.
Note that adding multiple conditions requires that all conditions must be met for the row to be deleted.
If however, we require that at least one out of the multiple conditions needs to be met, instead create multiple "Delete rows selectively" instructions.
For example, suppose we no longer require Nick's sales performance as well.
We can create another "Delete rows selectively" instruction.
But in this instruction, specify the following condition.
This will provide the following output.
The file containing the example used in this article can be downloaded below.
Comments
0 comments
Please sign in to leave a comment.