title: SSRS - Count elements in a delimited string
body: <p>Say I have this string: "1/r/5/dfg/998".  There are five elements delimited by a "/".  I'm looking for the simplest way to count the number of elements in that string in SSRS and would prefer not to write a custom code function.</p>
  
  <p>I know in SSRS split will make an array out of this string and I can use GetUpperBound(0) like this:</p>
  
  <p>split("1/r/5/dfg/998","/").GetUpperBound(0)</p>
  
  <p>The problem is this returns 4 not 5.  If there was a "/" at the end of the string it would return 5.  So I need to check for that and add 0 or 1 like so:</p>
  
  <p>split("1/r/5/dfg/998","/").GetUpperBound(0) + iif(right("1/r/5/dfg/998",1) = "/",0,1)</p>
  
  <p>That will give me 5.  Is there a simpler way to do this?  I wish I could just do</p>
  
  <p>count(split("1/r/5/dfg/998","/")) </p>
  
  <p>but that gives me an error.  Thanks for any suggestions!</p>