This is a migrated thread and some comments may be shown as answers.

The expression contains undefined function call ... calling user functions from a report group passing aggregate functions

4 Answers 358 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
kellyroberts
Top achievements
Rank 1
kellyroberts asked on 27 Oct 2011, 03:13 PM
Hi All - I know there have been other threads on this but OIY! this problem is a pain.  I am trying to get a grip on the issue with passing incorrect datatypes to user defined functions thus generating this error.

I have a simple test function

 

 

public static decimal hellodecimal(decimal arg1) { return arg1; }

 


doesnt get any more simple eh?

When I call this function from the detail section on a report it works well

=hellodecimal(Fields.SomeDecimalField)

BUT

If I call this from a group section and include an aggregate function, like ...

=hellodecimal(Sum(Fields.SomeDecimalField))

THEN I get the error  "The expression contains undefined function call hellodecimal()"

So it seems like "=Fields.SomeDecimalField"  and "=Sum(Fields.SomeDecimalField)" return different data types, is this true?

4 Answers, 1 is accepted

Sort by
0
Accepted
Patrick
Top achievements
Rank 1
answered on 27 Oct 2011, 05:36 PM
I've run into this issue before. IIRC, when using aggregates; i.e. Sum(), etc., the arguments are expected to be a double datatype. You have 2-options:

  1. Rewrite the function to accept doubles, vs. decimals
  2. Write an overload that accepts doubles

My preference would be #2.

Hope that helps...

--Patrick

0
kellyroberts
Top achievements
Rank 1
answered on 27 Oct 2011, 06:32 PM
Hi Patrick - Thanks for the help.  Good Info.  At first I didnt know what datatype the Sum() function would return so I wrote overloads with different data types until it stopped bombing out ... which happened to be,  as you noted below, when I changed the params to double.
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 28 Oct 2011, 07:55 AM
It just so happened the most precise expression data type in your case is double. This is what the documentation says for return type: Aggregate Functions.

Cheers
0
Joie
Top achievements
Rank 1
answered on 17 Apr 2013, 03:34 AM
Thanks Patrick!
Tags
General Discussions
Asked by
kellyroberts
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
kellyroberts
Top achievements
Rank 1
Massimiliano Bassili
Top achievements
Rank 1
Joie
Top achievements
Rank 1
Share this question
or