Creating segments from filter definitions

Besides creating segments in the dataset detail view, Cloudera Data Visualization also lets you create segments from a filter definition of a visual.

See the following topics to create a new segment from a filter in a visual, then edit the filter to add another segment, and finally update an existing segment.

Creating the first segment

Follow these steps to create a new data segment, Mountain from a filter definition:

  1. Start a new visual based on dataset Flight Delays, based on data previously imported into Data Visualization from a data file. See, Creating a visual.
  2. Add originstate to the Filters shelf.
  3. In the Filter for originstate window modal, select CO and WY, and click Apply.
  4. Click the Save Down icon to the left of the Filters shelf.
  5. From the menu, select Create New Segment.
  6. In the Add Segment window modal, specify the following:
    • Under Segment Name, enter Mountain.
    • Under Segment Group, enter Geographic Region.
    • Under Filters, notice the new filter expression, [originstate] in ('CO', 'WY').
    • Leave Entity to Extract field empty.
  7. Click Save.

    The new segment definition appears in Segments section on the right navigation menu.

Adding the second segment

Let's edit the filter defined in the first segment and create a second segment.

  1. On the Filters shelf, at the right of the originstate filter, click the Down icon to open the Filter Properties menu.
  2. From the Filter Properties menu, select Clear values.
  3. Click the Down icon to the right of the originstate filter to open the Filter Properties menu.
  4. From the Filter Properties menu, select Select values.
  5. In the Filter for originstate window modal, select WA.
  6. Click Apply.
  7. To define the next segment, select Create New Segment from the Save as Segment menu.
  8. In the Add Segment modal window, specify the following:
    • Under Segment Name, enter North West.
    • Under Segment Group, enter Geographic Region that we used earlier.
    • Under Filters, notice the new filter expression, [originstate] in ('WA').
    • Leave Entity to Extract field empty.
  9. Click Save.

Viewing the defined segments

  1. In the side navigation bar of the visual interface, click Segments.

    Notice that the two segments (and the segment group) we just defined appear in the Segments menu.

Adding values to an existing segment

Let's add a new state, OR, to our existing segment North West.

  1. Click inside the Filter shelf to open the Field Properties menu.
  2. Click Clear values.
  3. Click Select values.
  4. Select OR in the Filter for originstate window modal.
  5. Click Apply.
  6. To add the new selection to an existing segment, do the following:
    • Click Filters.
    • In the menu, select Add to Segment from the Save as Segment menu.
    • In the secondary menu, under Geographic Regions, select North West.

    Notice that when the Edit Segment modal window appears, it shows the existing configuration for the segment North West.

    However, its Filters specification now includes Oregon: [originstate] in ('WA', 'OR').

  7. Click Save to finish adding the specification to the segment.

To view how segments work in a visual, see Using Segments in Visuals