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.
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 errorPUBLIC FUNCTION PlanEff(BYVAL CompletedComplex AS INTEGER,BYVAL ACTUALHOURS AS INTEGER)DIM VALUE AS INTEGER=0IF CompletedComplex = 1 THENVALUE =VALUE +Sum(ACTUALHOURS)ELSEVALUE = 0END IFRETURN VALUE END FUNCTIONerror 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 warningswt 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 067 07 020 070 170 170 170 170 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)) |
|
|
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? |
|
|
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? |
|
|
shm
Yak Posting Veteran
86 Posts |
Posted - 2008-12-17 : 03:59:33
|
both are int datatype |
|
|
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") |
|
|
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.... |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-17 : 05:29:39
|
tried the last suggestion? any luck with it? |
|
|
|
|
|