SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


[rsAggregateOfMixedDataTypes] Warning


[rsAggregateOfMixedDataTypes] Warning

Author
Message
joshua.johnson
joshua.johnson
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 40
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
geoff5
geoff5
Say Hey Kid
Say Hey Kid (696 reputation)Say Hey Kid (696 reputation)Say Hey Kid (696 reputation)Say Hey Kid (696 reputation)Say Hey Kid (696 reputation)Say Hey Kid (696 reputation)Say Hey Kid (696 reputation)Say Hey Kid (696 reputation)

Group: General Forum Members
Points: 696 Visits: 543
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)))


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search