4 Replies Latest reply on Jan 3, 2018 8:44 AM by Mahfooj Khan

    Case Statement Error

    suvas.chandra

      I am finding error: Expected Type String, Found Float. How do I correct this:

       

      CASE MIN([Type])

      WHEN 1 THEN ""

      WHEN 2 THEN IF INDEX()<=[Top N Investments] THEN SUM([PaidIn])

                  ELSEIF INDEX()=[Top N Investments]+1 THEN WINDOW_SUM(SUM([PaidIn]),0,LAST()) END

      WHEN 3 THEN ""

      END

        • 1. Re: Case Statement Error
          Jim Dehner

          Hi

          Index returns a number and sum(Paid in) is a number  - the "" you have in your formula are strings - you need to replace the '' " a number - like 0

           

          Jim

          If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

          1 of 1 people found this helpful
          • 2. Re: Case Statement Error
            Michael Daddona

            Hi,

             

            It is hard to tell where the error is stemming from by the example without a sample of the data for reference, can you provide a sample workbook to review?

            • 3. Re: Case Statement Error
              Hari Chandan Reddy Maryada

              Hi Suvas,

               

              As mentioned it is expecting the return type to be string so just convert to string using STR() Function

               

              CASE MIN([Type])

              WHEN 1 THEN ""

              WHEN 2 THEN IF INDEX()<=[Top N Investments] THEN STR(SUM([PaidIn]))

                          ELSEIF INDEX()=[Top N Investments]+1 THEN STR(WINDOW_SUM(SUM([PaidIn]),0,LAST())) END

              WHEN 3 THEN ""

              END

              1 of 1 people found this helpful
              • 4. Re: Case Statement Error
                Mahfooj Khan

                Agree with Jim instead of " " you should try with 0

                 

                However, you may try this one also

                 

                CASE MIN([Type])

                WHEN 1 THEN INT(NULL)

                WHEN 2 THEN IF INDEX()<=[Top N Investments] THEN SUM([PaidIn])

                            ELSEIF INDEX()=[Top N Investments]+1 THEN WINDOW_SUM(SUM([PaidIn]),0,LAST()) END

                WHEN 3 THEN INT(NULL)

                END

                 

                Let us know if this help.

                 

                Mahfooj

                1 of 1 people found this helpful