3 Replies Latest reply: Dec 16, 2013 4:05 AM by Thomas Jensen RSS

    Numbering Rows more examples?

      Hi there,

       

      I was just reading a post this evening and i wanted to solve it, but i couldnt cause i do not have much experience within this and i think its hard to find good examples.

       

      IS there anyone with solid experience in when to use what when you want to number rows? I read HIC blog about Counters but its more explaination than examples.

       

      Let me show some examples i would like to be able to solve:

       

      CustomerDateAmountHowToGetThis?
      102-01-2013501
      102-01-2013502
      203-01-2013201
      303-01-2013341
      403-01-2013121
      404-01-2013232
      404-01-2013243
      504-01-2013241
      CustomerDateAmountHowToGetThis?
      102-01-2013501
      102-01-2013501
      203-01-2013202
      303-01-2013343
      403-01-2013124
      404-01-2013234
      404-01-2013244
      504-01-2013245
      CustomerDateAmountHowToGetThis?
      102-01-2013501
      102-01-2013501
      203-01-2013203
      303-01-2013344
      403-01-2013125
      404-01-2013235
      404-01-2013245
      504-01-2013248

       

       

      If it possible??

        • Re: Numbering Rows more examples?
          Peter Cammaert

          Yes, that's possible. This may not be the best solution but it works.

           

          When loading your ordered table (first Customer, then Date) use the previous() function to check the last record read and compare the Customer numbers. If they are equal, define [HowToGetHis?] with a value of the previous [HowToGetThis?] + 1, otherwise its value will be one.

           

          Something like:

           

          LOAD Customer, Date, Amount,

               if (previous(Customer) = Customer, previous([HowToGetThis?])+1, 1) AS [HowToGetThis?]

          FROM/RESIDENT/WHATEVER

           

          The second example isn't entirely clear to me... Are you duplicating the Customer Nr? Or do you want to continue counting whenever the Customer number changes? In the latter case, use the first example but substitute previous([HowToGetThis?]), previous([HowToGetThis?])+1 for the True/False clauses.

          For the third example you'll need the RowNo() value that is used whenever the Customer number changes. For all other rows with an identical Customer number, use previous() again.

           

          I don't have a QlikView version handy right now, so I'm unable to provide you with a model. Sorry.

           

          Good luck,

          Peter