Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jj5
Contributor III
Contributor III

Pull data from previous row if fields are blank

Hello,

I have a task where I'm given data that I need to populate from a previous record with the same unique ID.

It looks something like this:

 

Customer ID | Name | Address 1 | Address 2 | Purchase Date | Shop Address

1000 | Bob Smith | 123 Main St | Somewhere HI 12345 | 01/01/2020 | 111 Shop rd

1000 ||||03/01/2020| 123 Market Hw

2000 | Rachel Smith | 824 Open Rd | Beverly Hills CA 01879 | 04/01/2020 | 111 Shop Rd

3000 | Justin T | ...

 

The first time a new ID shows up we should have all the data. For the subsequent rows we only have the new data, everything omitted is assumed to be repeating and I need to populate it from the previous row as long as the Customer ID matches to the current line.

My expected outcome from the use case is as follows:

 

1000 | Bob Smith | 123 Main St | Somewhere HI 12345 | 01/01/2020 | 111 Shop rd

1000 | Bob Smith | 123 Main St | Somewhere HI 12345 | 03/01/2020| 123 Market Hw

2000 | Rachel Smith | 824 Open Rd | Beverly Hills CA 01879 | 04/01/2020 | 111 Shop Rd

3000 | ...

 

If there's a component that will allow me to do this with many fields I'd prefer that over java code using variables, I have around 30 fields that I'll need to utilize this solution for.

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi

I think tMemorizeRow component can meet your need, please refer to the component documentation and learn this component. Here I show you an example on tMap.

data source input-main--tMemorizeRow_1---tMap....>

0693p00000AasDSAAZ.png 

0693p00000AasCyAAJ.png 

Regards

Shong

View solution in original post

3 Replies
Anonymous
Not applicable

Hi

I think tMemorizeRow component can meet your need, please refer to the component documentation and learn this component. Here I show you an example on tMap.

data source input-main--tMemorizeRow_1---tMap....>

0693p00000AasDSAAZ.png 

0693p00000AasCyAAJ.png 

Regards

Shong

Anonymous
Not applicable

Hello,

As you have mentioned you want the solution without using custom code, you can do this in a tMap via if else expression.

https://community.talend.com/s/article/tMap-expression-syntax-TCiHW

Here is also a tMemorizeRows component which memorizes group key and columns on the previous row.

Best regards

Sabrina

 

 

 

Jj5
Contributor III
Contributor III
Author

Thanks @Shicong Hong​ and @Xiaodi Shi​. I'm not sure how to mark the topic as resolved but that's the solution I was looking for