As described in my previous blog post, the method used is an application of the modulo operator.
Example 1:
Let's say I had table where I had to carry out an operation every third row:
In this example, I want to output 'Hello' every three rows in the dataset.
To achieve this you have to use a formula tool:
You can also do this if the numbers are not 'nice'. Assuming the data is in the correct order, you need to add a Record ID tool before the formula tool:
After this step you can then remove the RecordID by using a Select tool.
Example 2:
In this example, I have some data from a YouGov survey about new and reintroduced sports at the 2020 Tokyo Olympics. Here's the link to the dashboard I created from this data, if you're interested.
In order to analyse the data I needed I had to assign each response to each question. However, this wasn't an easy task due to how the raw data was parsed because the data was originally in a pdf format.
Long story short, I had the data in the below format – minus the 'Question Number' column. The next step after this was to label the questions 1, 2, and 3 and then I wanted the question number to restart back at 1 (as shown in the 'Question Number' column).
In order to achieve this I had to use a Record ID tool and then a formula tool:
What this formula does is that it calculates the modulo of Record ID and outputs that number. However for every third record ID, the modulo of the Record ID equals zero which is not what we want to be output. Therefore we set the output to 3 as shown by the 'THEN 3'.