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
 error in the custom code

Author  Topic 

shm
Yak Posting Veteran

86 Posts

Posted - 2008-12-02 : 08:48:40
hi

am trying to write a custom code but it is giving error

PUBLIC FUNCTION PlanEff(BYVAL CompletedComplex AS INTEGER,BYVAL ACTUALHOURS AS INTEGER)

DIM VALUE AS INTEGER=0

IF CompletedComplex = 1 THEN
VALUE =VALUE +Sum(ACTUALHOURS)
ELSE
VALUE = 0
END IF
RETURN VALUE

END FUNCTION

error is :
[rsCompilerErrorInCode] There is an error on line 0 of custom code: [BC42021] Function without an 'As' clause; return type of Object assumed.

[rsCompilerErrorInCode] There is an error on line 5 of custom code: [BC30451] Name 'Sum' is not declared.
Build complete -- 1 errors, 1 warnings



wt am trying to get is there is two column one with the value 0 and 1,another column is number type..if col2 the row is 1,menas it can be more than one then i want to display the value as sum(col1)

col1 col2
--- ----
23 0
67 0
7 0
20 0
70 1
70 1
70 1
70 1
70 1


i want to get the result as 350

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-02 : 09:18:22
why do you need custom code for this? you just need below expression, if i understand you correctly

=SUM(IIF(Fields!Col2.value=1,Fields!col1.value,0))
Go to Top of Page

shm
Yak Posting Veteran

86 Posts

Posted - 2008-12-02 : 22:55:25
i tried that also it is giving error ,am placing the result in table footer.is this will give error?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-03 : 12:47:58
Whats the dataset used in table? is the field inside same dataset?
Go to Top of Page

shm
Yak Posting Veteran

86 Posts

Posted - 2008-12-17 : 03:59:33
both are int datatype
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-17 : 04:09:28
what about this?
=SUM(IIF(Cint(Fields!Col2.value)=1,Cint(Fields!col1.value),0),"Yourdataset")
Go to Top of Page

shm
Yak Posting Veteran

86 Posts

Posted - 2008-12-17 : 05:04:09
sorry i wanted to reply for other one which u asked...what are the datatype?
i replied to this....
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-17 : 05:29:39
tried the last suggestion? any luck with it?
Go to Top of Page
   

- Advertisement -