Count string values separated by comma in single column

I’m running Grafana 7.4 and pulling in data from an api using the JSON API plugin. I’m returning a column called ‘limit’ where I’m getting values separated by commas in a single string. I’m looking to get a count of the number of values within the string.
Alternatively, if one could do a character count searching for commas that would also be effective.

image

i.e. id 30093 would return a count of 6; id 30190 would return a count of 1

I looked into using transformations, regex, value mapping, etc. but could not find a way to do this within Grafana.

Edit: *id 30092 would produce a count of 6.

I know this is a very old post but is the only that I found on google with the same case as me. I finally found a solution and I hope that could be useful.

  1. Create a label and add the value using regex
regexp `(?s)will\s*(?P<LimitCount>.*)`
  1. Make a count of the commas using line_format
line_format `{{ .LimitCount | count "," }}`
  1. Add the count value in a new label using ‘pattern’
 pattern `<LimitTotal>`
  1. unwrap the new label (if you need to sum all occurrences from query)
unwrap LimitTotal

The final result should be something like this:

sum(sum_over_time({job="analyze"} | json | regexp `(?s)will\s*(?P<LimitCount>.*)` | line_format `{{ .LimitCount | count "," }}` | pattern `<LimitTotal>` | unwrap LimitTotal [$__auto]))