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.  How to perform a De-Aggregation

    Employee
    Posted 08-06-2013 03:00

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

    Originally posted by: ouwen010

    Hi,

    How can I perform a De-Aggregation? For the comparison of two sources that do not have a realy unique key, I need to create a key first. To do so I need to de-aggregate the dat of one source into single records. Currently that source contains records with a counter for the number of transactions. The de-aggregation means that I need to copy each record that counter-1 times. To make each record unique a key field is added that contains an increasing counter. I had thought of the following, but an emit or output is not accepted in the while loop. The S_AMOUNT contains the counter indicating the number of transactions. The S_GROUP is the unique key.
    # De-Aggregate records
    sAMOUNT=int(S_AMOUNT)

    i=0
    while i<sAMOUNT {
    # Give each record a unique ID to match second source
    S_GROUP=S_DATE+S_SNAME+S_TARIFF+str(i)
    output 1 {
    emit S_DATE, S_TARIFF, S_STATE, S_SNAME,S_GROUP
    exclude S_AMOUNT
    }
    i=i+1
    }


  • 2.  RE: How to perform a De-Aggregation

    Employee
    Posted 08-06-2013 07:13

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

    Originally posted by: stonysmith

    You need to use the "do output" feature.
    Setup a standard output statement, but add "where false" to it.
    Then use "do output" to cause it to actually write a record.

    You may not need the "id" field below, but I added it so that you could see the effect of changing data row to row.


    sAMOUNT=int(S_AMOUNT)
    output 1 {
    emit S_DATE, S_TARIFF, S_STATE, S_SNAME
    emit "" as S_GROUP
    emit 0 as id
    where false
    }

    i=0
    while i<sAMOUNT {
    # Give each record a unique ID to match second source
    S_GROUP=S_DATE+S_SNAME+S_TARIFF+str(i)
    do output 1 {
    emit S_DATE, S_TARIFF, S_STATE, S_SNAME,S_GROUP
    emit i as id
    }
    i=i+1
    }


  • 3.  RE: How to perform a De-Aggregation

    Employee
    Posted 08-06-2013 07:48

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

    Originally posted by: ltolleson

    Check out the graph I have attached and see if it solves what you are trying to do.

    Thanks,
    Larry
    Attachments:
    DeAggregationExample.brg


  • 4.  RE: How to perform a De-Aggregation

    Employee
    Posted 08-06-2013 07:56

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

    Originally posted by: ouwen010

    This is exactly the result I was looking for. Thanks!