The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

"Anyone please? Loop Attributes? -

MacPhotoBikerMacPhotoBiker Member Posts: 60 Contributor II
edited June 2019 in Help
Hi,

I'm trying to identify the first three orders when a particular customer purchased a particular product. The "integrate" operator could help to put a counter in each record, but I don't know how to reset it based on certain conditions (like "New customer and new article"). Here's what I try to achieve:
CustomerArticleCounter
C1A11
C1A12
C1A13
C1A21
C1A22
C2A11
C2A21


I'm hoping somebody could point me in the right direction.

Thank you!

Answers

  • MacPhotoBikerMacPhotoBiker Member Posts: 60 Contributor II
    The most promising operator seems to be the "Loop Operator".

    Here's how my table looks like currently:
    CustomerArticleCounter
    C1A11
    C1A11
    C1A11
    C1A21
    C1A21
    C2A11
    C2A21
    I want the operator to integrate "Counter" for every different Customer-Article combination. After the operator, the table should look like this:
    CustomerArticleCounter
    C1A11
    C1A12
    C1A13
    C1A21
    C1A22
    C2A11
    C2A21
    The best I came up with is this process, but it's not working:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.3.013">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.3.013" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="read_csv" compatibility="5.3.013" expanded="true" height="60" name="Read CSV" width="90" x="112" y="75">
            <parameter key="csv_file" value="/home/gert/Desktop/loop_table.csv"/>
            <parameter key="column_separators" value=","/>
            <parameter key="first_row_as_names" value="false"/>
            <list key="annotations">
              <parameter key="0" value="Name"/>
            </list>
            <parameter key="encoding" value="UTF-8"/>
            <list key="data_set_meta_data_information">
              <parameter key="0" value="Customer.true.polynominal.attribute"/>
              <parameter key="1" value="Article.true.polynominal.attribute"/>
              <parameter key="2" value="Counter.true.integer.attribute"/>
            </list>
          </operator>
          <operator activated="true" class="loop_attributes" compatibility="5.3.013" expanded="true" height="76" name="Loop Attributes" width="90" x="380" y="75">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attribute" value="Article"/>
            <parameter key="attributes" value="Article|Customer|"/>
            <process expanded="true">
              <operator activated="true" class="series:integrate_series" compatibility="5.3.000" expanded="true" height="76" name="Integrate" width="90" x="313" y="120">
                <parameter key="attribute_name" value="Counter"/>
              </operator>
              <connect from_port="example set" to_op="Integrate" to_port="example set input"/>
              <portSpacing port="source_example set" spacing="0"/>
              <portSpacing port="sink_example set" spacing="0"/>
              <portSpacing port="sink_result 1" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Read CSV" from_port="output" to_op="Loop Attributes" to_port="example set"/>
          <connect from_op="Loop Attributes" from_port="example set" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    And here's the data as csv:
    Customer,Article,Counter
    C1,A1,1
    C1,A1,1
    C1,A1,1
    C1,A2,1
    C1,A2,1
    C2,A1,1
    C2,A2,1
    C3,A3,1

    I'd really appreciate somebody could help me out.

    Thanks a lot in advance!
Sign In or Register to comment.