Pentaho

 View Only
  • 1.  How to create a group counter?

    Posted 03-11-2024 12:32

    Hi, someone could help me to create a group counter?  What I mean? I have a source with lot of register. In this source, I have two columns (customer and purchase) that repeat several times, due to the purchase items. One purchase can have one or more items. Now I want to create a column that counts the item. The first item for this composite key will be 1, the second 2, and so on. How can I create this item counter?

    Regards,
    Igor Bastos Martins



    ------------------------------
    Igor Martins
    Director of Sales
    Particular
    ------------------------------


  • 2.  RE: How to create a group counter?

    Posted 03-11-2024 13:30

    Hi Igor,

    aggregation functions provides Group by step, so check configuration or documentation.



    ------------------------------
    Petr Prochazka
    Systems Engineer
    P.V.A. systems s.r.o.
    ------------------------------



  • 3.  RE: How to create a group counter?

    Posted 03-11-2024 14:10

    Hi Petr,

    I thought about using group by step, but when I use this step, if I have 1000 lines, with 250  from 4 sellers, it aggregates them, removing the columns that are not part of the key and the output now has 4 lines and not the same 1000 ..


    The output I would like is:

    customer , purchase, item, vlv_item, qtd_item
    igor,1,banana,10,1
    igor,1,maça,15,2
    igor,1,pera,7,3
    igor,2,pão,2,1
    igor,2,leite,10,2
    maria,1,cafe,15,1
    maria,1,leite,10,2

    Regards, Igor Martins



    ------------------------------
    Igor Martins
    Director of Sales
    Particular
    ------------------------------



  • 4.  RE: How to create a group counter?

    Posted 03-11-2024 15:22

    Ok, you mean sequence number. So check step Add value fields changing sequence.



    ------------------------------
    Petr Prochazka
    Systems Engineer
    P.V.A. systems s.r.o.
    ------------------------------



  • 5.  RE: How to create a group counter?

    Posted 03-11-2024 20:42
    Would ROW_NUMBER() OVER (PARTITION BY <customer id=""> ORDER BY <customer></customer>
    id>) work if you have something like customer id number?