cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
lala
Level VIII

How can count the number of characters in a cell?

For example, how to count the number of line names with the first character of the name?

Thanks!

2020-12-28_16-32-43.png

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How can count the number of characters in a cell?

If I understand correctly what you want to do (calculate character count for the first character in name) you could do it with something like this:

  1. Get length of the name -> Length(:name)
  2. Remove first character from the name -> Substitute(:name, Left(:name, 1), "")
  3. Get length of the string where first character is removed -> Length(previous part)
  4. And finally calculate difference between these two strings

 

Length(:name) - Length(Substitute(:name, Left(:name, 1), ""))

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: How can count the number of characters in a cell?

If I understand correctly what you want to do (calculate character count for the first character in name) you could do it with something like this:

  1. Get length of the name -> Length(:name)
  2. Remove first character from the name -> Substitute(:name, Left(:name, 1), "")
  3. Get length of the string where first character is removed -> Length(previous part)
  4. And finally calculate difference between these two strings

 

Length(:name) - Length(Substitute(:name, Left(:name, 1), ""))

 

-Jarmo
Craige_Hales
Super User

Re: How can count the number of characters in a cell?

Clever! (And comment your code if you use this, the next person will appreciate explaining what you are doing!)

Craige