Knowledge Management

How many distinctly different characters are in a word?

automayt
Explorer

I have a field with strings and I want to calculate the amount of distinctly different characters that appear in the strings. For instance
rabbit - 5
Fox - 3
TabbYCaT - 5
Raptor - 6

I'd considered splitting every word and doing something like len(values()) but surely there is a more efficient way.

Tags (1)
0 Karma
1 Solution

jpolvino
Builder

Here is one way to do it:

| makeresults 
| eval album="abacab"
| makemv tokenizer="(.)" album
| eval album=mvdedup(album)
| eval c=mvcount(album)

This returns 3, which is the number of unique characters in the field named "album".

View solution in original post

0 Karma

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval test="rabbit,Fox,TabbYCaT,Raptor" |makemv delim="," test|mvexpand test
| eval result = mvcount(mvdedup(split(test,"")))
0 Karma

jpolvino
Builder

Here is one way to do it:

| makeresults 
| eval album="abacab"
| makemv tokenizer="(.)" album
| eval album=mvdedup(album)
| eval c=mvcount(album)

This returns 3, which is the number of unique characters in the field named "album".

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...