7 Replies Latest reply: Jan 16, 2012 2:29 PM by Erica Whalley RSS

    Store Qvd File with Today Date

      Hi Everyone,

       

           In my application, I am loading the qvw file file daily. So I want to store the Data into qvd with date suffix.

       

           I am using the below script to create qvds.

       

           Store Dinamalar_MoneyValue into Dinamalar_MoneyValue & '_'&$(vToday).qvd (qvd);

       

           vToday is the variable that I have created as Date(Today(),'DD-MMM-YYYY')

       

           It is not working, throw error while loading the file as in screenshot I have attached with this post.

       

           Let me know if you have any idea to achieve this.

       

      Thanks & Regards

      Rajan

        • Store Qvd File with Today Date

          Morning Rajan,

           

          Are you using LET or SET to define the variable?

           

          SETdefines it as a function, whereas LET will evaluate the function before storing to the vairable. to quote the helpfile

           

          Set x=3+4;

          Let y=3+4

          z=$(y)+1;

          $(x) will be evaluated as ' 3+4 '

          $(y) will be evaluated as ' 7 '

          $(z) will be evaluated as ' 8 '

           

          Let T=now( );

          $(T) will be given the value of the current time.

           

          In this instance you need to use LET.

           

          Also, when using the dollar sign expansion the variable may be evaluated as a direct text substitute in the expression.

           

          So your

               Store Dinamalar_MoneyValue into Dinamalar_MoneyValue & '_'&$(vToday).qvd (qvd);

          may be evaluated as EG

          4.50 & '_'&15-12-2011 - which would fail

          instead of

          4.5&'_'&'15-12-2011'.

           

          IE it is evaluating it as if you wrote it directly into the script.To solve this I place dummy quote characters around the variable when declaring it. There is no "escape" character so i use the character chr(39) concatenated with the rest of the text.

           

           

          Hope any of this helps.

           

          Regards,

           

          Erica

            • Store Qvd File with Today Date
              Stefan Wühl

              I agree with Erica in using a let statement in your variable definition:

               

              Let vToday = Date(Today(1),'DD-MMM-YYYY');

               

              (I recommend also to use an explicite timer_mode for today and other timer functions, I assume time at function call is what you want in the script).

               

              For the Store statement you just pass a filename without single quotes. The filename will not be evaluated for QV statements (besides dollar sign expansion), so there is no need to use concatenation operator & and single quotes to create a string

              (in fact, all these stuff will just be part of your file name: Dinamalar_MoneyValue & '_'&14-Jan-2012.qvd )

               

              This is probably not what you want, just use

                Store Dinamalar_MoneyValue into Dinamalar_MoneyValue_$(vToday).qvd (qvd);

               

              The dollar sign expansion will expand to your today's date, so the line will be evaluated as:

              Store Dinamalar_MoneyValue into Dinamalar_MoneyValue_14-Jan-2012.qvd (qvd);

               

              I believe this is what you want.

               

              You already formatted yor data with - as separators, which is good. If you use / as separator like in US style, this would be interpreted as folder path separator by the Windows OS.

               

              Hope this helps,

              Stefan

              • Store Qvd File with Today Date

                Thanks Erica.

                 

                I got the result and the script is now creating the qvds. Thanks a lot.

                 

                Regards

                Rajan

              • Store Qvd File with Today Date

                Thanks Stefan.

                 

                I didn't realise that you would get the '&' in there too, I've always passed the filename (unecessarily) in quotes. Learn something new!

                 

                What if I wanted to use a filename with eg a space in it, do you need to do someting else or can you just leave it... or just not pass the file to a path with spaces in it?

                 

                Erica

                  • Re: Store Qvd File with Today Date
                    Stefan Wühl

                    Erica,

                     

                    I usually try to avoid using spaces etc. in file / path names, but I know that sometimes you have to cope with it.

                     

                    I haven't found to much about the possible syntax of the filename in the Help, maybe I just missed the relevant.

                    But it's it quite easy to try, so let's see:

                     

                    It seems that you can just use spaces in your filename:

                     

                    Store INPUT into  TestStore_ $(vToday) b.qvd;
                    

                     

                    Notice the two spaces after _ and before b. The resulting filename is

                     

                    TestStore_ 2012-01-15 b.qvd
                    

                     

                    QlikView seems to parse the text after into a before the semicolon or a paranthesis as filename.

                     

                     

                    Store INPUT into  TestStore_ $(vToday) b.qvd (qvd);
                    

                     

                    Here, (qvd) is the file format indicator, not part of the filename. What, if you need paranthesis at the end of the filename (well, not really meaningful, but ...) or a space at the beginning?

                     

                    Put your filename in single quotes:

                     

                    Store INPUT into  ' TestStore_ $(vToday) b.qvd (qvd)';
                    

                     

                    Resulting filename is:

                     TestStore_ 2012-01-15 b.qvd (qvd)
                    

                     

                    Seems to work quite ok.

                     

                    If you use enclosing single quotes as well as single quotes inside:

                    Store INPUT into  ' TestStore_'&' $(vToday) b.qvd (qvd)';
                    

                     

                    you'll get all single quotes removed, like this:

                     TestStore_& 2012-01-15 b.qvd (qvd)
                    

                     

                    If you only use the inside single quotes,

                    Store INPUT into  TestStore_'&' $(vToday) b.qvd (qvd);
                    

                     

                    the single quotes are still kept as part of the filename, and the file format specifier is also still part of the file name, little strange.

                    TestStore_'&' 2012-01-15 b.qvd (qvd)
                    

                     

                    And if you use only one single quote:

                     

                    TestStore_'& 2012-01-15 b.qvd (qvd);
                    Let a = 10;
                    

                     

                    The file is stored with correct filename and without the (qvd), but the following statements are not syntax highlighted correctly and variable a is not set to 10.

                     

                    So I think spaces should not be a problem, you could get some more work if you want to use single quotes. Here I stopped for now.

                     

                    Regards,

                    Stefan