title: SSRS Error in custom code: expression expected
body: <p>I am using a couple of custom functions to perform some stats in SSRS. The code was built and tested in Visual Studio 2010, and works just fine when I try and preview the report. However, when I try and deploy the report to SSRS 2008R2 I get an error:</p>
  
  <pre><code>There is an error on line 40 of custom code: [BC30201] Expression expected.
  </code></pre>
  
  <p>I searched high and low for a solution to this problem, but I have yet to find one. Here's the problematic code:</p>
  
  <pre><code>Public Function Avrg(c1 As Double, c2 As Double, c3 As Double, c4 As Double, c5 As Double, c6 As Double, c7 As Double, c8 As Double, NumQuarters As Integer) As Double
      Dim AV_Data As Double() =
      IIf(NumQuarters = 1, {c1, c2, c3, c4, c5},
      IIf(NumQuarters = 2, {c1, c2, c3, c4, c5, c6},
      IIf(NumQuarters = 3, {c1, c2, c3, c4, c5, c6, c7}, {c1, c2, c3, c4, c5, c6, c7, c8})))
  
      Dim stats = STDEV_Ave(AV_Data)
  
      Avrg = stats(2)
  End Function
  </code></pre>
  
  <p>EDIT: Line 40 is apparently the function declaration (the first line presented)...though I can't find anything wrong with that. </p>
  
  <p>The function takes 8 parameters from the report and based on the number of non-archived quarters of data that the report is reading (which can vary from 1-4), the array declaration is different. That array feeds into a statistical function that performs the actual stats and returns the desired number. In this example, it's a simple average.</p>
  
  <p>I changed the code once, originally it was an if-elseif-else clause, but I read several places that I needed to replace that with a cascading IIF because SSRS's VB compiler is gimped.</p>
  
  <p>Any help would be greatly appreciated!</p>