Is there a way to create row numbers that count only when a value changes ...

Justin_21746
Justin_21746 Altair Community Member
edited November 2020 in Community Q&A

Hello,

I was wondering is there a way to create rows numbers that count only when a value changes, i.e. three rows of data, the first two row ids are CD and the third is TAPE, I would want it to restart the row count when the value changes from CD to TAPE.



------------------------------
Justin Marroquin
Financial Analyst
Dssw, LLC
San Antonio TX
(210) 845-6651
------------------------------

Tagged:

Best Answer

  • CPorthouse
    CPorthouse
    Altair Employee
    edited November 2020 Answer ✓
    Hopefully the following makes sense.  I am using classic.prn to create this example.  I skipped the modeling portion.  Once you have the data modeled, I added a couple of metadata columns (ReportPage and ReportLine):
    image
    I then grouped my table (Transform -> Group) on Order number and Media and aggregated on ReportPage and ReportLine (using the minimum):
    image


    I then combined by GroupBy table with the original Classic table using Combine->Join Tables->Lookup:
    image
    This will bring back the first row for each value change (Order # and Media).
    Add a formula column to calculate the difference between the minimum reportline and the original one and add 1 (so it won't be zero based):
    image
    Hopefully this gets you started.




    ------------------------------
    Chris Porthouse
    Professional services
    Altair
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 11-13-2020 12:39 PM
    From: Justin Marroquin
    Subject: Is there a way to create row numbers that count only when a value changes ...

    Hello,

    I was wondering is there a way to create rows numbers that count only when a value changes, i.e. three rows of data, the first two row ids are CD and the third is TAPE, I would want it to restart the row count when the value changes from CD to TAPE.

    ------------------------------
    Justin Marroquin
    Financial Analyst
    Dssw, LLC
    San Antonio TX
    (210) 845-6651
    ------------------------------

Answers

  • Baba_Majekodunmi_703
    Baba_Majekodunmi_703
    Altair Employee
    edited November 2020
    Hi @Justin Marroquin,

    I'm not sure this is possible in the way you're approaching it, but I am confident there may be another way within Monarch to address the your challenge.

    can you tell us a little bit more about what your goal is? What will having the row numbers changing dynamically help you accomplish?

    ------------------------------
    Baba Majekodunmi
    Solutions Consultant
    Altair Engineering Inc.
    Troy VA
    2405932495
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 11-13-2020 12:39 PM
    From: Justin Marroquin
    Subject: Is there a way to create row numbers that count only when a value changes ...

    Hello,

    I was wondering is there a way to create rows numbers that count only when a value changes, i.e. three rows of data, the first two row ids are CD and the third is TAPE, I would want it to restart the row count when the value changes from CD to TAPE.

    ------------------------------
    Justin Marroquin
    Financial Analyst
    Dssw, LLC
    San Antonio TX
    (210) 845-6651
    ------------------------------
  • CPorthouse
    CPorthouse
    Altair Employee
    edited November 2020 Answer ✓
    Hopefully the following makes sense.  I am using classic.prn to create this example.  I skipped the modeling portion.  Once you have the data modeled, I added a couple of metadata columns (ReportPage and ReportLine):
    image
    I then grouped my table (Transform -> Group) on Order number and Media and aggregated on ReportPage and ReportLine (using the minimum):
    image


    I then combined by GroupBy table with the original Classic table using Combine->Join Tables->Lookup:
    image
    This will bring back the first row for each value change (Order # and Media).
    Add a formula column to calculate the difference between the minimum reportline and the original one and add 1 (so it won't be zero based):
    image
    Hopefully this gets you started.




    ------------------------------
    Chris Porthouse
    Professional services
    Altair
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 11-13-2020 12:39 PM
    From: Justin Marroquin
    Subject: Is there a way to create row numbers that count only when a value changes ...

    Hello,

    I was wondering is there a way to create rows numbers that count only when a value changes, i.e. three rows of data, the first two row ids are CD and the third is TAPE, I would want it to restart the row count when the value changes from CD to TAPE.

    ------------------------------
    Justin Marroquin
    Financial Analyst
    Dssw, LLC
    San Antonio TX
    (210) 845-6651
    ------------------------------
  • Justin_21746
    Justin_21746 Altair Community Member
    edited November 2020

    Hopefully the following makes sense.  I am using classic.prn to create this example.  I skipped the modeling portion.  Once you have the data modeled, I added a couple of metadata columns (ReportPage and ReportLine):

    image
    I then grouped my table (Transform -> Group) on Order number and Media and aggregated on ReportPage and ReportLine (using the minimum):
    image


    I then combined by GroupBy table with the original Classic table using Combine->Join Tables->Lookup:
    image
    This will bring back the first row for each value change (Order # and Media).
    Add a formula column to calculate the difference between the minimum reportline and the original one and add 1 (so it won't be zero based):
    image
    Hopefully this gets you started.




    ------------------------------
    Chris Porthouse
    Professional services
    Altair
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 11-13-2020 12:39 PM
    From: Justin Marroquin
    Subject: Is there a way to create row numbers that count only when a value changes ...

    Hello,

    I was wondering is there a way to create rows numbers that count only when a value changes, i.e. three rows of data, the first two row ids are CD and the third is TAPE, I would want it to restart the row count when the value changes from CD to TAPE.

    ------------------------------
    Justin Marroquin
    Financial Analyst
    Dssw, LLC
    San Antonio TX
    (210) 845-6651
    ------------------------------
    Thank you, I implemented these steps into my solution and works just like I need it to. This tool continues to serve so many purposes.

    ------------------------------
    Justin Marroquin
    Financial Analyst
    Dssw, LLC
    San Antonio TX
    (210) 798-0123 Ext. 1913
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 11-16-2020 09:50 AM
    From: Chris Porthouse
    Subject: Is there a way to create row numbers that count only when a value changes ...

    Hopefully the following makes sense.  I am using classic.prn to create this example.  I skipped the modeling portion.  Once you have the data modeled, I added a couple of metadata columns (ReportPage and ReportLine):
    image
    I then grouped my table (Transform -> Group) on Order number and Media and aggregated on ReportPage and ReportLine (using the minimum):
    image


    I then combined by GroupBy table with the original Classic table using Combine->Join Tables->Lookup:
    image
    This will bring back the first row for each value change (Order # and Media).
    Add a formula column to calculate the difference between the minimum reportline and the original one and add 1 (so it won't be zero based):
    image
    Hopefully this gets you started.




    ------------------------------
    Chris Porthouse
    Professional services
    Altair
    ------------------------------

    Original Message:
    Sent: 11-13-2020 12:39 PM
    From: Justin Marroquin
    Subject: Is there a way to create row numbers that count only when a value changes ...

    Hello,

    I was wondering is there a way to create rows numbers that count only when a value changes, i.e. three rows of data, the first two row ids are CD and the third is TAPE, I would want it to restart the row count when the value changes from CD to TAPE.

    ------------------------------
    Justin Marroquin
    Financial Analyst
    Dssw, LLC
    San Antonio TX
    (210) 845-6651
    ------------------------------