Forum Discussion

MattLegowski's avatar
MattLegowski
Qrew Trainee
6 years ago

I need to create a code that counts how many time a particular codes appears in a field

I have the below string of codes in one quickbase field:

80346,80329,80346,80371,80346,80335,80324,80346,80369,80332,80332,80356,80361,80361,80361,80361,80354,80358,80372,80329,80324,80367,80355,80346,80360,80346,80366,80373,80368,80335,80353,80365,80346,80365,80324,80338,80332,80332,80349,80362,80359,80359,80335,80332,83992,80332,80354,80365,80358,80335,80373,80369,80346,80346,80329,80342

I need to create a code to count home many times a particular code (in this case "80361") appears in this string of numbers.

Below is a code that we were using to count how many entries were populated in that string:

Count([LCMS CPT Codes],1,"80332")

This code is returning 3 when there are 6 instances of this code.
Is there something in the code that is restricting the search?

Thanks


7 Replies

  • Hi Matt, 

    The Count function does not work the way you think it does. It's taking each of your items [LCMS CPT Codes],1, & "80332" and counting them... so there are 3.

    And while this explains why you're getting the response you got, it does not help you achieve your goal.

    What you are trying to do is not a simple task (although it ought to be). Is your string of text always the same length? Essentially what you'll have to do is parse out each 5 digit code (using Part and the comma delimiter) and compare it against your particular code and 'sum' the times it matches.

    -Sharon


  • Hi Dan, 

    Thank you for you response. 
    Unfortunately, I am not familiar with the Var Text Codes. 

    I copy and pasted your code and it is throwing an error for me. 

    Are you able to diagnose what is wrong with the code?



    https://imgur.com/a/uvz3JLD 

    It looks like the screenshot didn't upload that well, so a link to the image has also been added. 

    Thanks,

    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      It looks like there are no double quotes at the start and end of the second line of the formula.
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      Now you have two double quotes at the start and end of the second line.