Using logic4 Min.

# How to use text counters in your calculations

The calculator block is able to calculate with texts, for example to count characters, count words and even count occurrences of a certain text or character.

## When to use

Use the calculator block when you want to perform calculations inside your form. The calculator block can also work with text values. Sounds odd, but think of these use cases:

• Count the number of entered characters and show the amount of entered characters in your form;
• Count the number of entered words and show the amount of entered words in your form;
• Count the number of occurrences of a certain text so you can use that to analyse the entered text.

These are just some examples. Basically you can calculate anything you want with the calculator block. Please have a look at our calculator features overview to see everything you can do with the calculator block.

#### ðŸ“Œ Also see: Calculator block

In the article you're reading now we describe how to use text counters in your calculator blocks. For global instructions about the calculator block, please have a look at this article:

## How to use

You can use text counters inside each operation in combination with all text input fields.

From the menu to add an operation, you will see a list of questions in your form that you can use to calculate with. For the text input fields in your form the following options will be available:

• `Character count` - Count the amount of entered characters;
• `Word count` - Count the amount of entered words;
• `Line count` - Count the amount of entered line breaks;
• `Count occurrences` - Count the amount a certain text/character/regular expression occurs.

We will explain these options below.

### Setup text counters

There are several counters that can count the amount of characters, words and lines entered by the respondent in the selected text input field. Just add them as an operation in the calculator.

### Setup text analysis

A powerful tool to analyse the entered text is to count the occurrences of a certain text or character. By adding this as an operation you can specify which text/character you want to analyse.

For really advanced purposes you can even analyse text using regular expressions. This will count the occurrences of the regular expression that you enter.

## Example: keep track of entered characters

An often seen use case is you have a maximum amount of characters to enter in a text input field. And you want to show your respondent how many characters are left while they are typing. Let's see how we can set this up.

#### 1. Create text input

First simply add the text question you want to ask. And set the maximum amount of characters that can be entered by your respondent, for example `1000`.

#### 2. Add calculator block

Now, we want to keep track of the entered characters of calculate how many characters are left. To do so, we add a `Calculator` block and we give that block a name, for example `# Characters left`.

We start with the amount of maximum characters that can be entered, in this case `1000`.

And we add another operation that will subtract the amount of the already entered characters. You do that by adding a `Subtract` operationSelect the desired questionSelect `Character count`.

This calculator block will now hold the realtime amount of characters that are left for the respondent.

#### 3. Show counters

Back to the text input question. Let's say we want to show our counter in the help text of that question. You can show the value of the calculator by typing the `@` sign and select the calculator block.

The calculator block has lots of features, so we have several ways to learn all about it.

### Help center

Our help articles help you out on all different aspects of the calculator:

### Overviews

We also made some overviews of the capabilities that the calculator block provides: