LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Count unique

    Employee
    Posted 02-17-2014 05:56

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: aop

    Hi,

    I have a dataset containing invoice rows. In my project I have an agg for calculating total amounts based on the row level amounts. In addition I would like to include count() to count the number invoices in the data. If I use count() directly within in the agg with the kind of dataset I have it naturally counts invoice rows instead of unique invoices (multiple rows in the data for one invoice). What would be the way to get the the count of unique invoice numbers in scenario like this? If it is not otherwise possible I guess there is some way to do it by sorting the data by invoice number before the agg and then doing some if statement in the agg to add to count only if invoice number differs frfom previous iteration. Just not really sure who to do this exactly..

    I know I could always use two separate agg nodes and combine the results but I'd prefer to do it all in a single node as this is something I need to do on a regular basis.


  • 2.  RE: Count unique

    Employee
    Posted 02-17-2014 20:10

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    The way you say you already know how to do with more than one agg is the easiest to understand and maintain, so I would normally recommend doing it that way.

    But there are always exceptions, maybe if there is a very strong need for optimization. Attached is a graph given to me by Ted Czotter, once CTO of Lavastorm, when I was asking similar questions.
    Attachments:
    DemoCustomAgg.brg