Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jasonmomoa
Creator
Creator

Field API - Selecting dates with selectValues() not working

Hello everyone,

I am trying to call the Field API in my mashup in order to select a range of dates. I am trying to use selectValues() method. Everything is set up but the last step which communicates with the Qlik Sense API seems not to be working for me.

I first doubted about the date format not being the correct one with my data model; both of them have the 'mm/dd/yyyy' date format. As suggested in this thread, I also tried the qNumber value type without any success.

See below how other Field API methods still work with my 'Date' dimension:

app.field('Date').selectMatch('01/10/2018', true);             // Working

app.field('Date').selectValues('01/10/2018', true);            // Not working

app.field('Date').selectValues(['01/10/2018'], true);          // Not working

app.field('Date').selectValues([{qText: '01/10/2018'}], true); // Not working

app.field('Date').selectValues([{qText: "01/10/2018"}], true); // Not working

app.field('Date').selectValues([{qNumber: 01/10/2018}], true); // Not working

app.field('Week Number').selectValues([2], true);              // Working


How is that selectMatch() works with my date value as string format, but selectValues() does not? Can anyone give me some insights on this?

Thanks in advance,

X.

1 Solution

Accepted Solutions
theglenndavid
Partner - Contributor III
Partner - Contributor III

Looking at the help topic on this function there is a note saying: For a numeric field you need to provide the numeric value.

Dates are numeric in qlik so when using selectValues on date fields, you must use the numeric equivalent of the dates. i.e. to set the date filter to 11/09/1980, the function must be called with app.field('Date').selectValues([29475], true);  


View solution in original post

2 Replies
theglenndavid
Partner - Contributor III
Partner - Contributor III

Looking at the help topic on this function there is a note saying: For a numeric field you need to provide the numeric value.

Dates are numeric in qlik so when using selectValues on date fields, you must use the numeric equivalent of the dates. i.e. to set the date filter to 11/09/1980, the function must be called with app.field('Date').selectValues([29475], true);  


jasonmomoa
Creator
Creator
Author

Hi, first of all thank you for your prompt reply.

Looking at the Qlik's Date and Time documentation, I spotted the baseline

"Functions are based on a date-time serial number that equals the number of days since December 30, 1899. The integer value represents the day and the fractional value represents the time of the day."

I managed to create the conversion from a selected date in my frontend to a numeric value based on Qlik's conversion. Now the call to app.field('Date').selectValues([qlikNumDate], true); works like a charm!

Thank you very much for your help. Correct answer!