question

Hari.Devu avatar image
Hari.Devu asked

Translate Case stmt into an expression

Hi All, Can someone help me how to translate this case stmt into an rdl expression in ssrs 2005. CASE WHEN ISNULL(C.TRIP_NO,B.TRIP_NO)=9999 OR LTRIM(RTRIM(C.SCHED_TIME))='' OR C.SCHED_TIME IS NULL THEN '' ELSE (CASE WHEN SUBSTRING(C.SCHED_TIME,1,2)>=24 THEN CAST((SUBSTRING(C.SCHED_TIME,1,2)-24) AS VARCHAR) + SUBSTRING(C.SCHED_TIME,3,6)+' AM' ELSE (CASE WHEN SUBSTRING(C.SCHED_TIME,1,2)>=12 THEN C.SCHED_TIME+' PM' ELSE C.SCHED_TIME+' AM'END) END) Cheers, swanky
reporting-servicescase
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tomgough79 avatar image
tomgough79 answered
You could nest a load of IIf statements, but it's going to end up unreadable I suspect. Personally, I would stick with using the case statements in the SQL that the report uses - is there a reason why that isn't possible?
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hari.Devu avatar image
Hari.Devu answered
Hi Thanks ! Yes ; it is having a huge impact on performace of my report.hence i would like to handle the same in rdl.i even tried but was prmpted with an error. here is the expression i have used. =iif(Fields!Trip_Number.Value=9999 or Isnothing(Fields!SCHED_TIME.Value),"", (iif(Cstr(left(Fields!SCHED_TIME.Value,2)).Contains(":"),formatdatetime(Fields!SCHED_TIME.Value,3), (iif(Left(Fields!SCHED_TIME.Value,2)>=24,(Cstr(Left(Fields!SCHED_TIME.Value,2)-24)+ Cstr(Right(Fields!SCHED_TIME.Value,6))+" AM"), formatdatetime(Fields!SCHED_TIME.Value,3))) ) ) ) Can someone tell me where i was wrong !
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.