0

I want to convert this Crystal formula into SSRS Expression:

Formula:

 numberVar iDay := ToNumber(Right(Cstr({@PrntStartDate}), 2)) + 9;
    select iDay
     case 1 : {wk_TORIO0430_b.AcquisitionAmnt1}
     case 2 : {wk_TORIO0430_b.AcquisitionAmnt2}
     case 3 : {wk_TORIO0430_b.AcquisitionAmnt3}
     case 4 : {wk_TORIO0430_b.AcquisitionAmnt4}
     case 5 : {wk_TORIO0430_b.AcquisitionAmnt5}

How can I write this in SSRS Expression?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • What part of the conversion are you stuck on? May we see your work? – halfer Mar 05 '19 at 09:06
  • @halfer Thanks for Correcting my Mistake Sir, I am new to StackOver flow next time I will keep in mind about guideline – Rahul Shukla Mar 05 '19 at 10:37
  • @halfer Sir , I need to Convert this Crystal Report formula there are 43 formula like Above and I need to Convert them, So please I am requesting you if you know Something about it ,Please Help me. – Rahul Shukla Mar 05 '19 at 10:38
  • 1
    Do you already have a SSRS parameter to replace `{@PrntStartDate}`? Do you know conceptually what this expression is doing? The SSRS equivalent of `select case` is `switch`. The equivalent of `ToNumber` is `CInt` I think – Nick.Mc Mar 05 '19 at 11:53
  • How can iDay ever be 1 - 5 if you add 9 to (apparently) a day of the month? – Hannover Fist Mar 05 '19 at 20:52

1 Answers1

0

Not exactly sure what the first line of this is doing as I don't use Crystal Reports myself, but at Nick said in the comments, the select case can be rewritten using a switch statement. A possible solution to fix the first line would be to add a similar statement to a calculated field and using that field in the switch. You'll have to figure out the logic being used for the numberVar iDay line so you can put it in as it should be.

=SWITCH(Fields!iDay.Value = 1, wk_TORIO0430_b.AcquisitionAmnt1,
        Fields!iDay.Value = 2, wk_TORIO0430_b.AcquisitionAmnt2,
        Fields!iDay.Value = 3, wk_TORIO0430_b.AcquisitionAmnt3,
        Fields!iDay.Value = 4, wk_TORIO0430_b.AcquisitionAmnt4,
        Fields!iDay.Value = 5, wk_TORIO0430_b.AcquisitionAmnt5)
Steve-o169
  • 2,066
  • 1
  • 12
  • 21
  • I think iDay is a temp variable, not a field. The `Fields!iDay.Value` should be replaced with `VAL(Right(Cstr(Parameters!PrntStartDate.value), 2)) + 9`. – Hannover Fist Mar 05 '19 at 20:58
  • I couldn't decipher that first line, so I just answered the logic for the switch. He's going to have to figure out how to get `iDay` set to 1-5. If he responds and clarifies that line, I'll update my answer accordingly. – Steve-o169 Mar 05 '19 at 21:04
  • @HannoverFist Thanks for giving me solution Sir, But It won't worked ,I tried to replace numberVar iDay := ToNumber(Right(Cstr({@PrntStartDate}), 2)) + 9; over VAL(Right(Cstr(Parameters!PrntStartDate.value), 2)) + 9 this But I not able to understand how to Make all This Expression please help me. – Rahul Shukla Mar 06 '19 at 03:31
  • @Steve-o169 As I written above code iDay is Variable not a Parameter or Field it's Variable and I am not able to Make this SSRS Expression , Please Help me. – Rahul Shukla Mar 06 '19 at 03:38