2 Replies Latest reply: Oct 11, 2018 6:35 AM by Dilip Ranjith RSS

    Subfield Calculation

    Rahul Patel

      Hi,

       

      I do have a requirement where I have to check if any of the subfield data is greater than 0, I have a column(Attribute1) where data is in the format 0/43/61. Here I have to check the if any of the available three values are greater than zero, if yes it is Success or Failed.

       

      Finally I have to do a count of all the success and failures depending on the data. Can someone help me with the logic.

       

      Can we achieve it using Sub field function?

       

      Thanks,

        • Re: Subfield Calculation
          Dilip Ranjith

          use something like below in your script

          if(

               (SubField('0/43/61','/',1)+SubField('0/43/61','/',2)+SubField('0/43/61','/',3))>0

               ,1,0) as  SuccessCounter

           

          hope it helps

          • Re: Subfield Calculation
            Ruan Greeff

            Dilip that will not work unfortunately, because if you add all the values they will be greater than 0 even if one of the fields was 0.

             

            Instead, I would recommend doing the below in the script and just do a sum on the front end to get the count of the number of success or failures.

             

            if(SubField(TextField,'/',1)>0,IF(SubField(TextField,'/',2)>0,IF(SubField(TextField,'/',3)>0,1,0) )) as SuccessFlag

             

            if(SubField(TextField,'/',1)=0,IF(SubField(TextField,'/',2)=0,IF(SubField(TextField,'/',3)=0,1,0) )) as FailureFlag

             

            On the front end you can just sum(Successflag) or Failureflag