Qlik Community

Qlik Sense Data Connectivity

Discussion board where members can learn more about Qlik Sense Data Connectivity.

maxalander
New Contributor III

REST connector with automatic date update

Hi,

I'm using the REST connector in Qlik Sense to import data from Mixpanel to Qlik. This connection works fine and gives me the data I want but I have to specify a date range for the API to work properly. This means that I have to manually update the date range to include new data. I want this connection to always fetch the latest data.

In my REST connector I have several parameters, which includes "from_date" and "to_date" (as seen in the picture below).

Screen Shot 2017-08-16 at 16.27.01.png

I'm wondering if it's possible to automatically have the current date in the "to_date" parameter value?

If not, are there other ways do achieve this?

Thanks!

Max

1 Solution

Accepted Solutions
justinvchiang
New Contributor III

Re: REST connector with automatic date update

Hey Max,

One solve for this is to use a variable for your to_date.

1. In your load script, set a variable

LET vToday = date(Today(),'YYYY-MM-DD');

2. Leave the connection query parameters as you have them and then change the query parameter in your load script by using the WITH CONNECTION function which will override what you have stored in your connection:

FROM JSON (wrap on) "root" PK "__KEY_root"

WITH CONNECTION ( 

QUERY "to_date" "$(vToday)")

;

2 Replies
justinvchiang
New Contributor III

Re: REST connector with automatic date update

Hey Max,

One solve for this is to use a variable for your to_date.

1. In your load script, set a variable

LET vToday = date(Today(),'YYYY-MM-DD');

2. Leave the connection query parameters as you have them and then change the query parameter in your load script by using the WITH CONNECTION function which will override what you have stored in your connection:

FROM JSON (wrap on) "root" PK "__KEY_root"

WITH CONNECTION ( 

QUERY "to_date" "$(vToday)")

;

maxalander
New Contributor III

Re: REST connector with automatic date update

Hi Justin,

this is a great way of solving it!

I have just started to use, and learn how to handle, the WITH CONNECTION in other apps and forgot that I could use the same function here.

Thank you!

Community Browser