cancel
Showing results for 
Search instead for 
Did you mean: 

How to increment the counter (variable) based on the incoming data in snaplogic

srikotla
New Contributor

How to increment the counter (variable) based on the incoming data in snaplogic.

Source Data:

CostCenter, TestCompany
Test_Cost_Center_001,Test_company_1
Test_Cost_Center_001,Test_company_2
Test_Cost_Center_002,Test_company_1
Test_Cost_Center_002,Test_company_2
Test_Cost_Center_002,Test_company_3
Test_Cost_Center_002,Test_company_4

Target Data should be:

CostCenter, TestCompany, ID
Test_Cost_Center_001,Test_company_1, 1
Test_Cost_Center_001,Test_company_2, 2
Test_Cost_Center_002,Test_company_1, 1
Test_Cost_Center_002,Test_company_2, 2
Test_Cost_Center_002,Test_company_3, 3
Test_Cost_Center_002,Test_company_4, 4

Experts over here, please help in achieving the above solution using the right snap.

6 REPLIES 6

srikotla
New Contributor

Thank you So much sarathmattam,

I’m able to achieve this using mapper in the following way.

  1. Read the data in sorted order

  2. Generate the sequence

  3. Copy the data into two outputs

  4. For one o/p, Use Aggregate to find the min sequence grouping on the cost_center

  5. From other o/p join the data using the cost_center

  6. Use Mapper, and in one of the port define the logic as : (Value - min_Seq)+1

    Here Value is the sequence generated from the sequence snap

    Min_Seq is the minimum sequence value of the respective group obtained from aggregate snap.

unnamed

sarathmattam
New Contributor

Thanks for sharing your solution 🙂