4 Replies Latest reply: May 28, 2016 12:55 PM by Rohit Kumar RSS

    Append variable in Path String

    Rohit Kumar

      Hi,

      I am using QV Source for fetching Google Analytics data with the help of Qlik Sense.

      Task is to fetch the data from yesterday to today on words . So I have created two Variables :

       

       

      let vtemp = Date(timestamp(now(1)));

      let vtempP = Date(timestamp(now(1))-1);

      let vprofileId = 'XXXXXXXX';

       

      After Running the script in Browser I copied it and pasted it to script editor of Qlik sense and trying to execute it

       

      After Running the script in Browser I copied it and pasted it to script editor of Qlik sense and trying to execute it

      GoogleAnalyticsConnectorV3_DataFromTemplateQuery:

      LOAD

          dim_country as Country,

          metric_visits as metric_visits

      FROM

      [http://localhost:5555/QVSource/GoogleAnalyticsConnectorV3/?table=DataFromTemplateQuery&profileId=105153571&prebuiltQuery=dimensions%3dga%253acountry%26metrics%3dga%253avisits&startDate=01-01-2016&endDate=31-01-2016&appID=]

      (qvx);

       

      then replaced the static value to variables

       

      GoogleAnalyticsConnectorV3_DataFromTemplateQuery:

      LOAD

          dim_country as Country,

          metric_visits as metric_visits

      FROM

      'http://localhost:5555/QVSource/GoogleAnalyticsConnectorV3/?table=DataFromTemplateQuery&profileId=$(vprofileId)&prebuiltQuery=dimensions%3dga%253acountry%26metrics%3dga%253avisits&startDate=$(vtempP)&endDate=$(vtemp)&appID='

      (qvx);

       

      but it is giving me error that data has been not loaded. Can you please tell me what exactly I am missing or doing wrong ?

        • Re: Append variable in Path String
          Stefan Wühl

          I assumed your script runs fine with the hard coded values?

           

          Have you checked that the dollar sign expansion replaces your variables with text values in the same format as the hard coded values?

           

          Maybe add a date format:

           

          let vtemp = Date(Today(1),'DD-MM-YYYY');

          let vtempP = Date(Today(1)-1,'DD-MM-YYYY');

          let vprofileId = 'XXXXXXXX';

          • Re: Append variable in Path String
            Rohit Kumar

            Hi swuehl,

            Thanks for the help ,It is working fine , what I notice If i use your idea and put a variable of Today's date , It works fine now but later or next day it shows me error like data has been not loaded. Can you please tell me how to fetch data from a particular date to today , as I am looking to create an application which fetch data until today. But I don't wana do all the stuff , like go to QV source every time , select query there ,copy code and paste it here, If this I need to do , this is not a real time application.

            Please help me as this is an urgent requirement.

              • Re: Append variable in Path String
                Stefan Wühl

                If you do it manually and then compare the code with the variables being expanded (you should see this in the script editor debug window), do you see any differences?

                 

                Do you get a specific error message when running the code multiple times?

                 

                Maybe there is a limitation from the data source provider in the number of times you can call the API.

                  • Re: Append variable in Path String
                    Rohit Kumar

                    Thanks a lot, your suggestion are really helpful. What i Noticed , we must run first QVSource and then run authenticate after that if we run the script it loads the data from Google Analytics Source. So Now the question is  Do I need to run always QVSource manually or there is any way which makes qv source always run at back end  , for this time I am using a desktop application , May be on server side , If i run QVSource once so it will always run at  back end. Please correct me if I am on wrong Path.