Discussion Board for collaboration related to QlikView App Development.
Can't we use variable in Peek() function at the place where we write table name (3rd parameter)?
If yes, then what is the problem in following code (please refer to the screenshot below)?
The purpose is to get (26/01/2016 - 25/02/2016) for fieldname '1' (as per total number of days in January)
(26/02/2016 - 25/03/2016) for fieldname '2' (for feb) and so on.
As far as I know, the table name must be written in single quotes.
When I replace the darkened part in screenshot with
if($(i)=2,'FisTab',if($(i)=3,'FisTab-1',if($(i)=4,'FisTab-2','further if conditions'))) ,
I get the desired output. But then the if condition becomes too lengthy to be likely used.
I am attaching the .qvw file.
LOAD Date(MakeDate(2016,01,25)+RecNo(),'DD/MM/YYYY') as 1
LET tName = 'FisTab-'&$(tNum);
LET tName1 = 'FisTab-'&($(tNum)+1);
FOR i=2 to 12
LOAD Date(MakeDate(Year(Today()), $(i), Day(Peek($(i)-1,-1,'$(tName)'))) + RecNo(),'DD/MM/YYYY') as $(i)
LET tName = 'FisTab-'&($(tNum)+1);
LET tName1 = 'FisTab-'&($(tNum)+2);
View solution in original post
As Sunny has pointed out, the tablename parameter cannot be a calculated parameter. It must be a literal string. So doing the calculation into a variable as Sunny suggested should work.
Thanks Sunny... putting the third parameter variable in single quotes in my solution is working too...
But I got to learn about dynamically naming tables with alphanumeric values through your solution... I did not know that
Thanks a lot buddy...
Yeah, I was unaware of that... it being variable, I did not think of putting it in quotes...