Customizing enter/edit expressions

CDP Data Visualization provides you with an option to manually adjust expressions that modify the field values of the visual, the Enter /Edit Expression interface.

To set the customize expressions, follow these steps.

  1. Click the field you plan to modify, to open the Field Properties menu.
  2. Under Field Properties, click to expand the [ ] Enter/Edit Expression menu to open the Expression Editor.
  3. In the Enter/Edit Expression editor, change the expression.

    See Simple Alias expression and CASE expression examples for demonstration of some of the varied expressions you can build using the expression editor.

    1. Expression Text: Enter/modify the expression directly in the text field.

    2. Autocomplete: Click this field to turn expression autocomplete on or off.

    3. Functions: By default, all available functions show. Scroll down to find a specific function, and click it to add it to the Expression Text field. Note the location of the cursor.

      Alternatively, click the All Functions menu to see the function groupings and select the functions from these. Available expression groupings include Aggregate, Conditional, Mathematical, Miscellaneous, String, Filter, and Date and Time.

      Note that different connections have their own SQL syntax, and therefore a different catalog of functions.

    4. All Fields: By default, all available fields show. Scroll down to find a specific field, and click it to add it to the Expression Text field. Note the location of the cursor.

      Alternatively, click the All Fields menu to see the Measures and Dimensions groupings, and select the fields from these.

  4. Validate Expression: Validate the expression that you build.
  5. Click Save.
  6. Click Refresh Visual.

Simple Alias expression

You can add an alias to the expression simply by typing it in the text field:

sum([population]) as 'Population'

Remember to Validate Expression and click Save.

After clicking Refresh Visual, you will see a change similar to the one in the following image:

CASE expression

You can add a CASE expression to categorize the values, by selecting CASE in the functions area, and using autocomplete. The expression in this example follows; if you paste it into the editor, remove hard line returns:

CASE WHEN sum([population])<1000000 THEN 'very low' 
  WHEN (sum([population])<10000000 and sum([population])>=1000000) THEN 'low' 
  WHEN (sum([population])<20000000 and sum([population])>=30000000) THEN 'medium' 
  WHEN (sum([population])<40000000 and sum([population])>=30000000) THEN 'high' 
  ELSE 'very high' 
END 
as 'Population'

Remember to validate the expression and click Save.

After clicking Refresh Visual, you will see a change similar to the one in the following image: