4 Replies Latest reply: Feb 20, 2017 2:40 PM by Massimo Grossi RSS

    Count field Values

    Carlos Pulgarin

      Hello

       

      can someone help me with this?

       

      I have this colum

       

       

      Numero
      a
      a
      b
      b
      b
      c
      c
      c
      q
      q
      q
      q

       

      and y need  someting like this:

       

       

      NumeroCuenta
      a1
      a2
      b1
      b2
      b3
      c1
      c2
      c3
      q1
      q2
      q3
      q4
        • Re: Count field Values
          Nicole Smith

          In the load script, you can do something like this:

           

          Temp:
          LOAD * INLINE [
              Numero
              a
              a
              b
              b
              b
              c
              c
              c
              q
              q
              q
              q
          ];
          
          Data:
          LOAD Numero,
            IF(Numero = PREVIOUS(Numero), PEEK('Cuenta') + 1, 1) AS Cuenta
          RESIDENT Temp;
          
          DROP TABLE Temp;
          
          
          • Re: Count field Values
            Massimo Grossi

            Another option could be

             

            Temp: 

            LOAD * INLINE [ 

                Numero 

                a 

                a 

                b 

                b 

                b 

                c 

                c 

                c 

                q 

                q 

                q 

                q 

            ]; 

             

            Data: 

            LOAD Numero, 

              AutoNumber(Rowno(), Numero) as Cuenta

            RESIDENT Temp; 

             

            DROP TABLE Temp; 

            • Re: Count field Values
              Massimo Grossi

              Also Nicole's answer works.

               

              When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads as HELPFUL if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads as HELPFUL if you feel additional info is useful to others.