Splitting the stream upon conditions

In the previous examples, we applied a filter and discarded the rows that didn't match a given condition. It may be the case that you don't want to discard any row. You might simply want to apply different treatments to the rows that match and those that don't match a particular condition. This can be accomplished in a simple way. Suppose that you want to separate the locations with private rooms from the rest of the locations:

  1. Create a transformation and read the files containing the surveys.
  2. After the input step, add a Filter rows step. 
  3. Double-click the step and use it to create the Room_type = Private room filter.
  4. Drag two Dummy steps from the Flow folder to the work area.
We are using the Dummy steps as placeholders for testing purposes. You can use any step instead if you prefer.
  1.  Create a hop from the Filter rows step toward one of the Dummy steps. When asked for the kind of hop, select Result is TRUE.
  2. Now create a hop from the Filter rows step toward the other Dummy step. This time, select Result is FALSE. Feel free to rename the Dummy steps as well. At this point, you should have something similar to the steps shown in the following screenshot:
Transformation with a Filter rows step
  1. Click on the first Dummy step and run a preview. You will only see the places with private rooms:
Previewing some data
  1. Click on the second Dummy step and run a preview. You will only see the places with room types different from private rooms.

If you take a look at the Step Metrics, you will see that the Filter rows step passes all the rows—the number of rows entering the step is the same as the number of rows leaving the step. Also, looking at the Read column, you will see that the whole set is split in two: The rows that match the condition—4696—are read by one Dummy step while the rest of the rows are read by the other Dummy step, as shown in the following screenshot:

Step Metrics
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset