How to sum a column that has column dependencies?

  • I have a table in my report that has a column with an expression:

    =IIF(Fields!FieldA.Value="Y",0,Fields!FieldB.Value)

    The table is grouped by another field.

    I need to sum this column in the group footer but simply using:

    =Sum(IIF(Fields!FieldA.Value="Y",0,Fields!FieldB.Value))

    results in RS error:

    The Value expression for the textbox ‘textbox21’ 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.

    I assume this is because the expression in the Group Footer references a field that has multiple values throughout the group.

    Can anyone tell me how to sum a column like the one described above?

     

  • You can add a calculated field NewField to your dataset with the expression

    =IIF(Fields!FieldA.Value="Y",0,Fields!FieldB.Value)

    Now can summarize on the field NewField in the group footer.

    Peter

  • That's what I did. Turns out the error message was that the "0" in the expression and the field value were different data types. I changed the formula to use Cdbl() on both fields to make them both doubles and it worked.

     

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply