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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikviewforum
Creator II
Creator II

Adding month to the Variable

I have a variable called zDates='2016_07'. I need to check whether QVD's with the date already exists in appropriate location or not.

Name of the QVD will be as below.

Employee_M.2016_05.qvd
Employee_M.2016_06.qvd

In this case since 2016_07 qvd does not exists in the file system I need to add that date to the variable. So the variable now should have zDates='2016_07','2016_06'.

If the value in the variable is zDates='2016_06' then there wont be any changes in the varaible it will remain same. That is zDates='2016_06'

If the file system contains below qvd's and the variable zDates='2016_01' then in that case the variable should be updated to zDates='2015_12',2016_01'

Employee_M.2016_11.qvd

Employee_M.2016_12.qvd


Can someone help me to achieve this?

32 Replies
adamdavi3s
Master
Master

Cool, hopefully you can just tweak that code until it works!

qlikviewforum
Creator II
Creator II
Author

Yes I am trying to do that. But I am getting the below error not sure why.

Script line error:

let zSecondLoadDates = if(replace('''2016_07'',''2016_09''','_','') = 201607,left('''2016_07'',''2016_09''',4)&'_'&right('''2016_07'',''2016_09''',2),

     left(201607,4)&'_'&right(201607,2))

I think value in the variable is something like below

zSecondLoadDates='2016_07'

Any idea how this can be handled?

adamdavi3s
Master
Master

Hmmm so the variable includes the ' already?

if so then take that out of the replace statement so

if(replace('$(zDates)','_','')


becomes


if(replace($(zDates),'_','')


It looks like you just have too many ' going on!

qlikviewforum
Creator II
Creator II
Author

The variable already contains value like below

zSecondLoadDates='2016_07'

If the new date has to be added then it should be something like below

zSecondLoadDates='2016_07','2016_06'

Not sure how this can be handled

qlikviewforum
Creator II
Creator II
Author

it tried doing this but it didn't work.

Yes too many thing going on. Not been able to focus

qlikviewforum
Creator II
Creator II
Author

Sorry I think I had two values in zSecondLoadDates='2016_07','2016_09' so it was getting failed.

adamdavi3s
Master
Master

ahhhh yes I can see that now in your error, sorry I am not awake yet!

qlikviewforum
Creator II
Creator II
Author

Sorry this didn't work either

qlikviewforum
Creator II
Creator II
Author

Sorry to disturb you. Please check if you can help on this as it is very urgent.

adamdavi3s
Master
Master

what error do you get now you only have one item in the variable?