Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

[rsAggregateOfMixedDataTypes] Warning Expand / Collapse
Author
Message
Posted Thursday, June 20, 2013 1:10 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 26, 2013 9:21 AM
Points: 1, Visits: 9
I'm just starting with SSRS and I have an expression that gives me the sum that I'm looking for, but I still get the warning:

Warning 1 [rsAggregateOfMixedDataTypes] The Value expression for the textrun ‘Textbox83.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.

This is my current expression:

=sum(Cdec(iif(Fields!UserField1.Value = 1, (Fields!UserField2.Value), Cdec(0))))

I've tried various types of conversion as well as code and no matter what I do I get that warning message.

UserField1.Value will be either a 0 or 1
UserField2.Value is a Decimal value and can be NULL although looking at the database there are no nulls, but there are Zeros.

Like I said I'm getting the right totals, but this is a test database and not very large. I'm concerned that this will cause issues down the road. Any ideas?

Thanks
Post #1465906
Posted Sunday, June 23, 2013 9:12 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, August 21, 2014 7:49 PM
Points: 171, Visits: 501
Sometimes the order of operations can have a significant effect on the way SSRS interprets the results of nested functions. It would probably be best to put the CDec function directly on the field2 value rather than wait to put it on the entire IIF() function. Like this:

= Sum(IIf(Fields!UserField1.Value = 1, CDec(Fields!UserField2.Value), CDec(0)))

Post #1466561
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse