KNOWLEDGE BASE

Counting Occurrences of a String Within a Dimension


Published: 20 Jan 2014
Last Modified Date: 09 Nov 2023

Question

How to count the number of times a particular text string occurs within a dimension.

Environment

Tableau Desktop

Answer

Option 1:

Use a calculation similar to the following to count how many times the substring occurs in any value of the dimension [String].

COUNT(IF CONTAINS([String],"substring") THEN 1 END)

Or alternatively

SUM(INT(CONTAINS([String],"substring")))

Option 2:

Use a calculation similar to the following to count occurrences of a string value within a dimension:

COUNT
(IF
CONTAINS([DIMENSION],'VALUE') == TRUE THEN [DIMENSION]
END)
 
Did this article resolve the issue?