1 Reply Latest reply on Oct 25, 2018 9:24 PM by swaroop.gantela

    Expect 'Then' to Match 'If' at Character 0

    Elizabeth Coleman

      Hello,

      Need help with this If - Then - Statement I am getting an error message,

       

      Please review and let me know what I need to change.

       

      IF ATTR([Has Risk])

      AND

      SUM(

          IF

              NOT(ISNULL([Backlog Status]))

              AND [Backlog Status] = "Scheduled - Forecast Risk"

          THEN

              [Risks]

      Else 0

      END

      )> 0

          ELSEIF ATTR([Is Upside])

      AND  

      SUM(

          IF

              NOT(ISNULL([Backlog Status]))

              AND [Backlog Status] = "Scheduled ? Upside"

          THEN

              [Upside Equip]

      ELSE 0

       

       

       

       

      END

      )

      >0

        • 1. Re: Expect 'Then' to Match 'If' at Character 0
          swaroop.gantela

          Elizabeth,

           

          I didn't quite catch the logic, so I apologize at the outset if I'm way off base.

          I think what is missing in both parts is what value to return.

           

          If you are seeking to return a Boolean, then you can try re-writing it as:

          (ATTR([Has Risk])

          AND

              SUM(

                  IF NOT(ISNULL([Backlog Status]))

                      AND [Backlog Status] = "Scheduled - Forecast Risk"

                  THEN

                      [Risks]

                  Else 0

                  END

                  )> 0

          )

          OR

          (

          ATTR([Is Upside])

              AND

              SUM(

                  IF NOT(ISNULL([Backlog Status]))

                  AND [Backlog Status] = "Scheduled ? Upside"

                  THEN

                  [Upside Equip]

                  ELSE 0

                  END

                  ) >0

          )

           

          Otherwise, you will need a THEN return clause:

          IF ATTR([Has Risk])

          AND

              SUM(

                  IF NOT(ISNULL([Backlog Status]))

                      AND [Backlog Status] = "Scheduled - Forecast Risk"

                  THEN

                      [Risks]

                  Else 0

                  END

                  )> 0

          THEN SUM([Risks])

           

          I made a revision which I think accomplishes the same:

          IF ATTR([Has Risk])

          AND NOT(ISNULL(ATTR([Backlog Status])) )

          AND ATTR([Backlog Status]) = "Scheduled - Forecast Risk"

          THEN SUM([Risks])

            

          ELSEIF ATTR([Is Upside])

          AND NOT(ISNULL(ATTR([Backlog Status])))

          AND ATTR([Backlog Status]) = "Scheduled ? Upside"

          THEN SUM([Upside Equip])

          ELSE 0

          END

           

          Please see workbook v10.3 attached in the Forum Thread:

          https://community.tableau.com/thread/285898