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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
MaSo1996
Contributor II
Contributor II

Load value from previously loaded column from current row

Hello Fellow Qlik-Enjoyers!

Since yesterday I'm trying to create table with 7 columns, that are calculated based on previously loaded in the same row columns. Below script, I'm currenty using and doesn't work, as I ecpect:

NoConcatenate
TempTable:
load
ParentItem,
if(IsNull(Product2),peek(ParentItem),Product2) as Product2,
if(IsNull(Product3),peek(Product2),Product3) as Product3,
if(IsNull(Product4),peek(Product3),Product4) as Product4,
if(IsNull(Product5),peek(Product4),Product5) as Product5,
if(IsNull(Product6),peek(Product5),Product6) as Product6,
if(IsNull(Product7),peek(Product6),Product7) as Component
Resident BoM_2024;

The idea for me is following - if present value I try to get is empty, I want it to be value from prvious column - this is how the table BoM_2024 looks like:

ParentItemProduct2Product3Product4Product5Product6Product7
VPC430OEL_0000VPC430OELKAPTUR180----
VPC430OEL_0000VPC430OELKGGL250_0000----
VPC430OEL_0000VPC430OELL3063----
VPC430OEL_0000VPC430OELL3073----
VPC430OEL_0000VPC430OELL3083----
VPC430OEL_0000VPC430OELLTANGENTIAL----
VPC430OEL_0000VPC430OELSO.201.10.005----
VPC430OEL_0000VPC430OELVPC.201.13.7700----
VPC430OEL_0000VPC430OELVPC.201.13.61190----
VPC430OEL_0000VPC430OELVPC.201.201OEL----
VPC430OEL_0000VPC430OELVPC.201.3550----
VPC430OEL_0000VPC430OELVPC.201.4550-1----
VPC430OEL_0000VPC430OELVPC.201.4550GRAU----
VPC430OEL_0000VPC430OELVPC430HZOELVPC.201.611---
VPC430OEL_0000VPC430OELVPC430HZOELVPC.201.630---
VPC430OEL_0000VPC430OEL81300701----
VPC430OEL_0000VPC430OEL81400605----

 

And this is, what I would like to achievie:

ParentItemProduct2Product3Product4Product5Product6Product7
VPC430OEL_0000VPC430OELKAPTUR180KAPTUR180KAPTUR180KAPTUR180KAPTUR180
VPC430OEL_0000VPC430OELKGGL250_0000KGGL250_0000KGGL250_0000KGGL250_0000KGGL250_0000
VPC430OEL_0000VPC430OELL3063L3063L3063L3063L3063
VPC430OEL_0000VPC430OELL3073L3073L3073L3073L3073
VPC430OEL_0000VPC430OELL3083L3083L3083L3083L3083
VPC430OEL_0000VPC430OELLTANGENTIALLTANGENTIALLTANGENTIALLTANGENTIALLTANGENTIAL
VPC430OEL_0000VPC430OELSO.201.10.005SO.201.10.005SO.201.10.005SO.201.10.005SO.201.10.005
VPC430OEL_0000VPC430OELVPC.201.13.7700VPC.201.13.7700VPC.201.13.7700VPC.201.13.7700VPC.201.13.7700
VPC430OEL_0000VPC430OELVPC.201.13.61190VPC.201.13.61190VPC.201.13.61190VPC.201.13.61190VPC.201.13.61190
VPC430OEL_0000VPC430OELVPC.201.201OELVPC.201.201OELVPC.201.201OELVPC.201.201OELVPC.201.201OEL
VPC430OEL_0000VPC430OELVPC.201.3550VPC.201.3550VPC.201.3550VPC.201.3550VPC.201.3550
VPC430OEL_0000VPC430OELVPC.201.4550-1VPC.201.4550-1VPC.201.4550-1VPC.201.4550-1VPC.201.4550-1
VPC430OEL_0000VPC430OELVPC.201.4550GRAUVPC.201.4550GRAUVPC.201.4550GRAUVPC.201.4550GRAUVPC.201.4550GRAU
VPC430OEL_0000VPC430OELVPC430HZOELVPC.201.611VPC.201.611VPC.201.611VPC.201.611
VPC430OEL_0000VPC430OELVPC430HZOELVPC.201.630VPC.201.630VPC.201.630VPC.201.630
VPC430OEL_0000VPC430OEL8130070181300701813007018130070181300701
VPC430OEL_0000VPC430OEL8140060581400605814006058140060581400605

 

You have any ideas, how to achieve that?

Labels (3)
1 Solution

Accepted Solutions
lennart_mo
Creator
Creator

Hi @MaSo1996,

As far as I know, Qlik isn't able to reference calculated values from the same row, peek would in this case return the value from the previous row.

To achieve your desired output I'd probably use the coalesce function (coalesce - script and chart function | Qlik Sense on Windows Help), which returns the first string <> NULL from multiple expressions.

So the loadscript for your output might look something like this:

NoConcatenate
TempTable:
load
ParentItem,
coalesce(Product2, ParentItem) as Product2,
coalesce(Product3, Product2, ParentItem) as Product3,
coalesce(Product4, Product3, Product2, ParentItem) as Product4, 
coalesce(Product5, Product4, Product3, Product2, ParentItem) as Product5, 
coalesce(Product6, Product5, Product4, Product3, Product2, ParentItem) as Product6, 
coalesce(Product7, Product6, Product5, Product4, Product3, Product2, ParentItem) as Component
Resident BoM_2024;

View solution in original post

2 Replies
lennart_mo
Creator
Creator

Hi @MaSo1996,

As far as I know, Qlik isn't able to reference calculated values from the same row, peek would in this case return the value from the previous row.

To achieve your desired output I'd probably use the coalesce function (coalesce - script and chart function | Qlik Sense on Windows Help), which returns the first string <> NULL from multiple expressions.

So the loadscript for your output might look something like this:

NoConcatenate
TempTable:
load
ParentItem,
coalesce(Product2, ParentItem) as Product2,
coalesce(Product3, Product2, ParentItem) as Product3,
coalesce(Product4, Product3, Product2, ParentItem) as Product4, 
coalesce(Product5, Product4, Product3, Product2, ParentItem) as Product5, 
coalesce(Product6, Product5, Product4, Product3, Product2, ParentItem) as Product6, 
coalesce(Product7, Product6, Product5, Product4, Product3, Product2, ParentItem) as Component
Resident BoM_2024;

MaSo1996
Contributor II
Contributor II
Author

Thank You @lennart_mo , this is exactly what I needed!