Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Share your agentic AI experience, learn from others, and earn a new badge: Put Agentic AI to Work
cancel
Showing results for 
Search instead for 
Did you mean: 
jeanjpotgieter
Contributor II
Contributor II

tMemorizeRow only filling blank data once

Good morning, 

 

I have a use case where I need to pull a description field down from a previous row if the IDs match:

 

ID | Description|

100|Apple|
100||
100||
100||
101|Banana
102||
103|Kiwi|

should end up like this:
100|Apple|
100|Apple|
100|Apple|
100|Apple|
101|Banana
102||
103|Kiwi

 

I'm using the tMemorize row component. I have 2 rows memorized and I have the ID and Description checked on the tMemorize_Row component. 

In my tMap I have logic that says: Relational.ISNULL(row1.Description) && row1.ID.equals(ID_rMemorizeRows_1[1]) ? Description.tMemorizeRows_1[1]
:row1.Description

It works fine for pulling in the first blank, but then pulls in nothing after that, so I'm getting:
100|Apple|
100|Apple|
100||
100||
...

How do I get it to pull down blank descriptions an unspecified amount of times?

Labels (2)
6 Replies
DaniZ
Partner - Contributor III
Partner - Contributor III

Hi,

If you are constantly memorizing the incoming rows, then from the 3rd row it will memorize a null description. It keeps memorizing the 2 LAST rows that were moved through main, and doesn't work retroactively, so it correctly remembers the empty description in the previous row once it get to the 3rd row.

To get what you want you would need to store the value you want to remember in a context or use the Var section of the tMap to create a retrospective lookup. tMemorizeRow is not really required here, though you could use it to reference the previous ID instead of using a code check if the ID changed. 

jeanjpotgieter
Contributor II
Contributor II
Author

Thanks for the reply but I wasn't able to solve the issue so I must be doing something wrong. 

I have a tFileInputExcel feeding into the tMap. I've created two variables and defined them as:

prevDesc [!Relational.ISNULL(Var.currentDesc) && Var.currentDesc.length() > 0 ? Var.currentDesc :""]
currentDesc [row1.Description]

 

Then in my output column I have Description defined as:

[Var.currentDesc.length() > 0 ? Var.currentDesc :Var.prevDesc]

 

I expected that the prevDesc would hold the value of Var.currentDesc because it hasn't been set for the current row yet but it's doing the same thing that the tMemorizeRows did, only copying down a blank value once. Am I doing the retrospective lookup incorrectly? 

DaniZ
Partner - Contributor III
Partner - Contributor III

You need something like this in the tMap var section:

PrevDesc --> row9.Description == null ? Var.prevdesc : row9.Description

PrevID --> Var.prevID == null ? row9.ID : Var.prevID

CurrentDesc --> row9.Description == null && row9.ID.equals(Var.prevID) ? Var.prevdesc : row9.Description  

jeanjpotgieter
Contributor II
Contributor II
Author

Thanks, I got it working but the logic for setting the previous ID is wrong, it's always grabbing that first ID and never updating it. I solved it by creating two variables called prevID and newID that says

prevID: [Var.newID = null ? "" :Var.newID]
newID: [row1.ID]

Then I updated the prevDesc variable to say [(row1.Description == null || row1.Description.length() < 1) && Var.oldID.equals(Var.newID) ? Var.prevDesc :row1.Description]

DaniZ
Partner - Contributor III
Partner - Contributor III

Happy it worked out.

BTW - You COULD have used tMemorizeRow before the tMap just to get the current and previous IDs without having to use the extra Var to determine prevID...

jeanjpotgieter
Contributor II
Contributor II
Author

Noted. I was already creating vars so I figured might as well keep it consistent