Can i count the number of repeated items in array column

Hello,
I have the below lookup column with data array, Can i count how many “C” and how many “D” etc.
Count Reply by Code
Thank you

Steps to reproduce:

  • Create a joined list column from the array, returning it in a form like this: “C, C, C, C, C, C , D, C, C, B, C” (just an example, not the same as your image")

  • Add a JavaScript column and use this code.

let arr = p1.split(", ");
let count = 0;

for (i = 0; i < arr.length; i++) {
if(arr[i] == p2) {
count += 1;
}
}

return count;

Then use p1 as the list, p2 as the text you want to count the number of occurrences for.

2 Likes

First of all, Congratulation to the new Professional Title “Certified” you really deserve more.

to be Honest, i would never come up with such solution in my own.
Really thank you

2 Likes

Hola @Hani_Ibrahim

If you want to test another workaround, you can take a look at this 🔢 Count duplicate elements in an array or list

Both solutions work fine, no problem with Thinh’s one.

2 Likes

i will try that too.

Thank you for your continues support.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.