Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Custom Code

Author  Topic 

Basim
Starting Member

1 Post

Posted - 2013-01-14 : 01:12:39
Hi,

Wrote a Custom Code i.e. a function.
Can not refer to this function from an expression area. It says unrecognized identifier.


Public dim pct_total as double
Public dim p_dept as string
Public dim p_rname as string
Public dim p_proj as string


Public function add_pct(byval dept as string,byval rname as string,byval proj as string,byval pct as double) as double

If p_dept <> dept or p_rname <> name or p_proj=proj then
pct_total=pct_total+pct
End If


p_proj=proj
p_dept=dept
p_rname=rname

return pct

End Function

Public function get_total_pct() as double
return pct_total
end function



=Code.add_pct(Fields!Departments.value,Fields!ResourceName.Value,Fields!ProjectName.Value,Fields.Percentage.Value)


=Code.get_total_pct()


Any thought please ?


James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-14 : 03:01:41
I don't see anything obviously wrong with your report that can cause that error to be generated - unless you are using a custom assembly and not referencing the custom assembly. Compare what is described on this MSDN page to see which of the two approaches you are using --> http://msdn.microsoft.com/en-us/library/ms156028.aspx

Another problem - although you have not run into it yet - is that if you are using SSRS 2008 or later global variables may not behave the way you expect them to. In 2008 and later, the order in which expressions are evaluated is not guaranteed. So the results you get may not be what you expect. A better option would be to use report variables or group variables if at all possible.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-14 : 03:22:10
sorry didnt understand why you want to nest functions like this. Why not return total from first function itself?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -