Built-in Functions → caseContains
caseContains() is a conditional statement that returns a specified case sensitive string value if the input field contains the specified string, else returns another string value.
Signature
caseContains(string field, boolean caseSensitive, string caseValue, string thenValue, ..., string elseValue)
The following table illustrates the caseContains() conditional statement parameters:
Parameter | Description |
---|---|
string field | The input field value to compare |
boolean caseSensitive | True enables a case sensitive string comparison |
string caseValue | The value compared against the string field value |
string thenValue | The value returned as a result of matching codes, if the string field value contains the string caseValue |
string elseValue | The value returned as a result of non-matching codes, if the string field value does not contain the string caseValue |
Returns
String
representing the thenValue
and elseValue
in the column.
Example
This example maps the regions that contain “As” with “Asia” with respect to case sensitivity, and maps all other regions with "Other”.
caseContains(SALES.COUNTRIES.COUNTRY_REGION,true,"As","Asia","Other")
Use the following steps for detailed instructions on how to use the caseContains() conditional statement:
Note
In the Cluster Management Console (CMC), you can create a tenant that includes Sample Data. The Sample Data includes the SALES schema.
- In the Navigation bar, select the Content tab, and then select + New → Add Dashboard.
- In the Add Dashboard dialog, for Name, enter Product Dashboard, and then select Add.
- In the Action bar, select + (add icon), or select + Add Insight.
- In the Insight panel, select Listing Table or V.
- In Tables, select Aggregated Table.
- In the Data panel, select Manage Dataset (+).
- In the Manage Data Sets panel, in Tables, select SALES. Close the panel.
- From the Data panel, drag and drop the following columns to the respective tray:
- Revenue from the SALES table to the Measure tray
- Region from the COUNTRIES table to the Grouping Dimension tray
- From the Data panel, drag and drop Add Formula to the Grouping Dimension tray.
- The Formula Builder automatically opens:
- In Search Functions, select the down arrow, and then select Conditional Statements.
- Double-click the second caseContains function,
caseContains(string field, boolean caseSensitive, string caseValue, string thenValue, ..., string elseValue)
, to add the formula to the editor. - In the Formula Editor,
- Replace
string field
with Region from the Data panel - Replace
boolean caseSensitive
with true - Replace
string caseValue
with “As” - Replace
string thenValue
with “Asia” - Replace
string elseValue
with “Other”
- Replace
caseContains(SALES.COUNTRIES.COUNTRY_REGION, true, "As", "Asia", "Other")
- Select Validate & Save.
- In the Properties panel, for Column Label, enter caseContains() Boolean
- Name the insight Revenue Per Region.
- In the Action bar, select Save.