cancel
Showing results for 
Search instead for 
Did you mean: 

Can We create a Variable in Mapper

Karan_Mhatre
New Contributor II

Hello Everyone,

I am trying to create an incremental addition let say i have 2 columns empl_id and salary so in target i want to derive third column with cumulative salary.

I can do it by using variable, have done it using Different tool but never implemented it in snaplogic

Hence the question can we create Variable in mapper?

any help is appreciated

21 REPLIES 21

Preeta
New Contributor II

Thank you responding . Here is the input and expected output
count Date product
2 2008-01-31 ABC
1 2008-07-31 ABC
2 2009-01-31 ABC
1 2009-04-30 ABC
3 2009-07-31 ABC
3 2009-10-31 GEF
5 2010-01-31 GEF
1 2010-04-30 GEF
3 2010-07-31 GEF

output :
Sum Date product
2 2008-01-31 ABC
3 2008-07-31 ABC
5 2009-01-31 ABC
6 2009-04-30 ABC
9 2009-07-31 ABC
3 2009-10-31 GEF
8 2010-01-31 GEF
9 2010-04-30 GEF
12 2010-07-31 GEF

Anil
New Contributor III

@PreetavariableInMapperNew_2019_09_18.slp (9.9 KB)

Please find the attached pipeline.

Preeta
New Contributor II

Hi Tim,
Thank you for your reply.
Even if I concatenate , the issue here would be that it would generate a cumulative sum for all the records while I want to get the cumulative sum grouped by each product. In the above solution , the ruuid is same for all the records while i need a new ruuid for each group of same product records.

Hope that makes sense.

Thanks ,
Preeta

Sorry should have looked at your example before replying. I see what you’re saying… I think I’d probably group all the elements into an array by the product, then use that array to build the cumulative results, and then map everything back to the original structure. Not sure if that makes sense, but let me give it a try.

tlikarish
Employee
Employee

Think this should work for your use case. Think some of the expressions could be simplified, but hopefully clear enough to follow.

accum-by-date_2019_09_17.slp (9.5 KB)