title: For loop inside a formula in crystal reports
body: <p>Say I want to find the ten most common things in a list. Crystal reports allows you to do this easily one by one with the Nthmostfrequent function. I am curious if we can do this a bit more efficiently say using a for loop.. </p>
  
  <p>I tried </p>
  
  <pre><code>local numbervar i;
  local stringvar result;
  local stringvar result = nthmostfrequent(i,{ticket.diagnosis});
  for i :=1 to 10 do
  (
      nthmostfrequent(i,{ticket.diagnosis});
      i := i+1;
  );
  result;
  </code></pre>
  
  <p>But it doesn't work saying a number is expected at i in the formula.</p>
  
  <p>Edit: thinking I also need to initialize an array to house the results?
  Any help is very much appreciated!</p>