# Question regarding a transformation

**URL:** <https://forum.cloverdx.com/t/question-regarding-a-transformation/2028>\
**Category:** CloverDX Platform\
**Created:** [March 12, 2019, 12:00am UTC](https://forum.cloverdx.com/t/question-regarding-a-transformation/2028 "2019-03-12T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![evangeloslef](https://avatars.discourse-cdn.com/v4/letter/e/c68b51/32.png) [@evangeloslef](https://forum.cloverdx.com/u/evangeloslef)\
**Post date:** [March 12, 2019, 12:00am UTC](https://forum.cloverdx.com/t/question-regarding-a-transformation/2028/1 "2019-03-12T00:00:00Z")

</div>

Hello,

I am trying to create a unique ID using a specific Date format.  
In my graph I use a reformat component.  
In my reformat component I have some inputs 2 of them are:  
- $in.0.Total → This is the total number of records that I am passing through.  
- $in.0.ID → This record is null

What I did I created a While statement that I wanted to create a unique value in very spicific way and in that while loop to assign a each ID to the record.

The following is the while statement is what I used in the reformat:

integer i;  
integer a;  
integer b=getMillisecond(today(),“GMT”);  
integer c = $in.0.Total;  
while (i != c) {

$out.0.ID =“”+ getYear(today(),“GMT”)+getMonth(today(),“GMT”)+getDay(today(),“GMT”)+getHour(today(),“GMT”)+getMinute(today(),“GMT”)+getSecond(today(),“GMT”)+b;  
i++;  
b++;  
};

The logic into this is that I create an ID using the format (Year,Month,Day,Hour,Minutes,Seconds,Milliseconds)

I set a parameter b that is the Milliseond.

A parameter i that will start from - and go increment by 1 until I get all the values inserted into my IDs.

A parameter c that is equal into the number of records I have so I can run the while statement that many times.

My expectation is that if I had 20 records it will get the first id = 201931232756954 and then it will increment by 1 for all the other records.

My problem is that when I use this while statement is that is assigning the same value (first ID) into all the records.

How to change this transformation in order to make it work as I want?

I attached an example of my output.

- [ID.JPG](https://cdn.cloverdx.com/forum/18855%5F62839174a4b8ef4360918ddfbad30f3f/ID.JPG)

---

<div class="post-metadata">

**Author:** ![Vladimir\_Barton](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/vladimir_barton/32/167_2.png) [@Vladimir\_Barton](https://forum.cloverdx.com/u/Vladimir_Barton)\
**Post date:** [March 12, 2019, 3:05pm UTC](https://forum.cloverdx.com/t/question-regarding-a-transformation/2028/2 "2019-03-12T15:05:38Z")

</div>

Hello Evangeloslef,  
I might be missing some crucial parts of your use case but from what you described, it seems there might be an easier way of how to approach this challenge. I am also a little bit on the fence as to how exactly the input data looks like. Therefore, I took the liberty of manufacturing a set of examples demonstrating various scenarios:

- incrementID.grf  
I assume that there is a set of data without IDs and the goal is to set the ID on each record with an incremental number at the end. Worth noting is that I took advantage of the [sequences](https://doc.cloverdx.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/sequence-functions-ctl2.html?resultof=%22%73%65%71%75%65%6e%63%65%22%20) feature in CloverDX.

- incrementID2.grf  
This is the same idea but without using sequences but a simple incrementing variable inside the Reformat component instead.

- incrementID3.grf  
I don’t assume the set of data and I only work with the total count. I am using the Normalizer component to create multiple IDs with the desired format based just on the input count of records.

- incrementID4.grf  
This is the fourth scenario that I perceived as possibly desired from your question. Again, I assume a set of data without IDs and I also assume that you would want to increment the millisecond “suffix” at the end of the ID. Worth noting is the transformation code of the Reformat component where I resolve the milliseconds separately and then add up an incremental number for each record.

Kind regards,

- [incrementID.grf](https://cdn.cloverdx.com/forum/18401%5Fd319e1373a2be00d8abe7dff3e06592a/incrementID.grf)
- [incrementID2.grf](https://cdn.cloverdx.com/forum/18401%5F834cb087c543cc4c02b8ab9436b687a6/incrementID2.grf)
- [incrementID3.grf](https://cdn.cloverdx.com/forum/18401%5F22d8d87d75116d3c0ff1764783c45044/incrementID3.grf)
- [incrementID4.grf](https://cdn.cloverdx.com/forum/18401%5F88fc972bcd87a7fc368576832372fe52/incrementID4.grf)

---

<div class="post-metadata">

**Author:** ![evangeloslef](https://avatars.discourse-cdn.com/v4/letter/e/c68b51/32.png) [@evangeloslef](https://forum.cloverdx.com/u/evangeloslef)\
**Post date:** [March 13, 2019, 7:24pm UTC](https://forum.cloverdx.com/t/question-regarding-a-transformation/2028/3 "2019-03-13T19:24:31Z")

</div>

Hello Vladimir Barton,

That was really helpful.  
Actually incrementID2 is what I needed and I now understand better how to use it next time.

Thank you for the help,

Evangelos Lefkonikiatis
