Link to home
Start Free TrialLog in
Avatar of djehmli
djehmli

asked on

SQL Server 2005 Reporting Services - uses an aggregate function on data of varying data types error

New to Reporting Services and .Net as of yesterday <grin> from many years as a Crystal report user.  

I have this formula in my detail as a column:

= IIf(Fields!AGNGBUKT.Value = 1,Fields!CURTRXAM.Value,0)

Which gives me detail as follows:
Current
0
0
4.55
1.25
0

I am grouping by customer and I want to sum this field at the group level.



=Sum(
 IIf(Fields!AGNGBUKT.Value = 1,Fields!CURTRXAM.Value,0)
 ,"Customer")

if I preview and my column detail results are

0
4.55
1.25
0

I am getting the following error:
[rsAggregateOfMixedDataTypes] The Value expression for the textbox ‘CustCurrentSum’ 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.

if I preview and my column detail results are
1.25
4.55
3.00

My sum works perfectly

After doing some research it looks like because CURTRXAM is a currency field it does not translate the 0 as also being a currency? Instead it is an integer?

So this is really my detail result?

0 integer
1.25 currency
1.65 currency
0 integer

and it is puking trying to summarize what it thinks are different data types?

So how do I indicate that the zero in the following function should be considered a currency type too?

= IIf(Fields!AGNGBUKT.Value = 1,Fields!CURTRXAM.Value,0)

This specific 'manual crosstab' scenario is one I am going to run into extensively trying to translate Reports desinged in Crystal to RS 2005, I appreciate any assistance in understanding the syntax and what exactly isn't working.

Thanks again
Julie
Avatar of djehmli
djehmli

ASKER

I found the answer to my question, in case any other new user to Report Services and .Net runs into the same scenario.


= IIf(Fields!AGNGBUKT.Value = 1,Cint(Fields!CURTRXAM.Value),0)

I had to change the currency field to integer.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial