Hi. Have this custom code in SSRS report which have had in use for ages now...[code="vb"]Public Function cvtSecondToHHMMSS(Second As Integer) As String Dim hr as Integer'Hours can be greater than 24 Dim mi as Integer Dim sec as Integer hr = int( Second / 3600 ) mi = int( ( Second - ( hr * 3600 ) ) / 60 ) sec =int( Second MOD 60 ) Return Cstr(hr)+":"+Right("0"+Cstr(mi), 2)+":"+Right("0"+Cstr(sec), 2)End Function[/code] If in a Tablix cell I have this value expression to calculate an average...[code="vb"]=iif(CountRows()=0,"na",code.cvtSecondToHHMMSS(Sum(Fields!DurationSecs.Value)/CountRows()))[/code]it renders #Error when that row/column has no records, but all other row/column have correct result.However, if in adjacent cell inside group, I have either of these value expressions...[code="vb"]=iif(CountRows()=0,"na",code.cvtSecondToHHMMSS(Avg(Fields!DurationSecs.Value)))[/code] or[code="vb"]=iif(CountRows()=0,"na",Sum(Fields!DurationSecs.Value)/CountRows())'no conversion[/code] they work in all cases...Ok so I know the answer... But I dont know why? Anyone? SSRS 2012Best regards Dave.
↧