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.  Segmentation Analysis

    Employee
    Posted 03-01-2010 07:08

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

    Originally posted by: rpcwong

    I'm wondering if there is a better way to approach this than what I have in mind. Whenever I need to run data through a graph for segmented and non-segmented analysis, for example, segment = 0, 1, 2, 3 where segment = 0 is the same as non-segmented. I will need to have the data pass through the same graph two times,
    one to do the segmented analysis,
    the other to do the non-segmented analysis (basically the rollup of 1, 2 and 3).

    One graph will agg without the segmentID, the other one with...

    Is there a more efficient way to handle this type of analysis? Can agg nodes export the sorted data + the rollup sum?


  • 2.  RE: Segmentation Analysis

    Employee
    Posted 03-01-2010 07:19

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

    Originally posted by: rpcwong

    how to combine daily and monthly analysis into the same graph, where the monthly is just a rollup of the daily results?


  • 3.  RE: Segmentation Analysis

    Employee
    Posted 03-02-2010 11:14

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

    Originally posted by: rboccuzzi

    An agg node can certainly output both the rolled up and full data. In order to do that, just add a second output to the agg, and have your code look like this:

    someSumData = sum('SomeField')

    output 1 {
    emit *
    }

    output 2 {
    # emitting {{^GroupBy^}} will output your GroupBy fields, if it is
    # just a field or list of fields. Otherwise, leave that out, and emit
    # the other fields you want.

    emit {{^GroupBy^}}, someSumData
    where lastInGroup
    }

    Does this solve your problem? Please let us know if you need more assistance.

    Cheers
    Rich


  • 4.  RE: Segmentation Analysis

    Employee
    Posted 03-02-2010 11:45

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

    Originally posted by: rpcwong

    Actually, i don't think your solutoin would do what i wanted,
    For example, lets say:

    TotalPrice = sum(Price)

    emit Date, Color, TotalPrice
    where lastInGroup

    GroupBy
    Date, Color

    Normally, the output would give me the TotalPrice of each color of each day..
    I'm wondering if I can also get the TotalPrice of allcolors (in a way, a value GroupBy Date only) with the same node (so I don't have to use two agg nodes)...


  • 5.  RE: Segmentation Analysis

    Employee
    Posted 03-03-2010 11:12

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

    Originally posted by: rboccuzzi

    Ok, I am not sure why you wouldn't want to run two aggs, one on the Date, Color, and then a second after the first, on the first's output, on just the date. You wouldn't have to sort again, and the meaning would be pretty straightforward and easy to follow.

    If you really want to do it in one agg though, you could maybe do something where you agg on Date,Color, and you keep a running total, as well as do the subtotal for each date/color correctly. You are still going to be putting out all the rows, and you only know the date already changed, not that it was about to change, so you can't limit the output on another output, but the data is correct, if you look at the correct rows, if you follow.

    Here is the code to do that:
    if execCount == 1 then
    lastDate = null

    if execCount == 1 or lastDate != Date then
    TotalPrice = 0

    TotalSubPrice = sum(Price)
    if lastInGroup then
    TotalPrice = TotalPrice + TotalSubPrice

    emit *, TotalPrice, TotalSubPrice
    where lastInGroup

    lastDate = Date

    Cheers
    Rich