Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am trying to create multiple QVDs from another QVD based on the Booking Year. I have this code in my script (orginally from this post https://community.qlik.com/t5/QlikView-App-Dev/How-to-create-Year-wise-Qvd-dynamically/td-p/1637440) -
Your struggling is caused from peek() which starts with an index of 0. This means by looping from 1 to noofrows() you will skip the first value which won't result in a load-error but the max. value from noofrows() is greater as the max. possible index-value for peek() which results in NULL for peek() and this will remove the variable.
Therefore just use as iteration-logic:
for n = 0 to noofrows('table') - 1
and then you could call $(n) within the peek().
Beside this if there are any performance-issue with this data-set there would be a lot potential to optimize this slicing approach.
Presumably, one of the steps in the sequence that populates the year isn't correct. I'd suggest running the code in debug mode and following the steps to see where it goes wrong.
first can u check is any value stored in vYear variable,if yes then can u place variables in single quotes like where [Booking Year] = '$(vYear)';
It looks like vYear does not have any values stored in it.
It will run if I add quotes - 'vYear' , but it doesn't generate the QVDs (no data)
Thank you. When I step through, vYear is not populated so it must be something in
let vYear = Peek('[Booking Year]',$(n)-1,'TempYear');
I haven't figured what is going wrong there.
seems below script not functioning ,can u check what $(n) output while running
let vYear = Peek('[Booking Year]',$(n),'TempYear');
The code you originally posted is:
let vYear = Peek('[Booking Year]',$(n),'TempYear');
Adding the -1 should be correct, but your original code doesn't seem to have that?
[Edit] That said, the issue here is the square brackets. They need to be removed.
try executing below code
let vYear = Peek('[Booking Year]',n,'TempYear');
Yes it should have -1. My mistake when I posted the original code. I was testing n.
It does not work if I hard-code the middle value (n). It fails on the first value.
Using
let vYear = Peek('[Booking Year]',n,'TempYear');
It fails with the original error