title: Calculating Weighted Average in Reporting Services 2008
body: <p>I am trying to calculate average weighted value for each group item in my report. I used all of the suggestions at <a href="http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/cef96df9-17b5-450b-a112-989fe7fd5004" rel="nofollow">this link</a>, but all of them give me the following error:</p>
  
  <blockquote>
    <p>Warning   1   [rsAggregateOfMixedDataTypes] The Value expression for the
    textrun ‘textbox134.Paragraphs[0].TextRuns[0]’ uses an aggregate
    function on data of varying data types.  Aggregate functions other
    than First, Last, Previous, Count, and CountDistinct can only
    aggregate data of a single data type.</p>
  </blockquote>
  
  <p>Any suggestion for the best way to calculate weighted average. My latest attempt is this:</p>
  
  <pre><code>=iif(sum(iif(Fields!weight.Value is nothing,0,Fields!weight.Value))= 0, 0, sum(iif((Fields!myData.Value * Fields!weight.Value) is nothing,0,(Fields!myData.Value * Fields!weight.Value)))/ sum(Fields!weight.Value))
  </code></pre>
  
  <p>Thanks</p>