Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
clondon
Contributor II
Contributor II

How to filter `GetTableData` method in QIX Engine API

I have successfully connected to my client's app using the QIX Engine API using server-side websockets.  I have also successfully queried all of their table fields and table data.  This is great for a one time initial data load but I want to, on a daily basis, get all of the new data.  In the table there is a $numeric $timestamp field.  I would like to use something like `GetTableData` where $timestamp field is greater than yesterday.

How do I do this?

Labels (1)
  • SaaS

1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee

The `GetTableData`method is primarily intended to create previews of data and is used for instance in the "Preview" section of the data model viewer. It's not really intended for the type of data extraction you are asking for here and does not support filtering.

What you need to do is to create a hypercube and extract the data that way. You can either do the filtering by selecting the dates you want to, then extract the data using `GetHyperCubeData`, or you can use a calculated dimension and do the filtering that way. If you go with the latter approach, then you could use an expression like this to get a column based on a table column called "Timestamp" that is null for all values that are older than 1 day:

 

=if(Timestamp > Now()-1, Timestamp)

 

If you add that dimension to a hypercube, then choose to exclude null values, then you got what you're looking for. If you want to have all values since midnight yesterday, then you could just add the `floor`function around `Now` like this:

 

=if(Timestamp > floor(Now())-1, Timestamp)

 

An introduction to hypercubes in the engine API can be found here:

https://community.qlik.com/t5/Qlik-Design-Blog/Let-s-Dissect-the-Qlik-Engine-API-Part-4-Hypercubes/b...

View solution in original post

4 Replies
clondon
Contributor II
Contributor II
Author

@rwunderlich Do you have any advice?

Øystein_Kolsrud
Employee
Employee

The `GetTableData`method is primarily intended to create previews of data and is used for instance in the "Preview" section of the data model viewer. It's not really intended for the type of data extraction you are asking for here and does not support filtering.

What you need to do is to create a hypercube and extract the data that way. You can either do the filtering by selecting the dates you want to, then extract the data using `GetHyperCubeData`, or you can use a calculated dimension and do the filtering that way. If you go with the latter approach, then you could use an expression like this to get a column based on a table column called "Timestamp" that is null for all values that are older than 1 day:

 

=if(Timestamp > Now()-1, Timestamp)

 

If you add that dimension to a hypercube, then choose to exclude null values, then you got what you're looking for. If you want to have all values since midnight yesterday, then you could just add the `floor`function around `Now` like this:

 

=if(Timestamp > floor(Now())-1, Timestamp)

 

An introduction to hypercubes in the engine API can be found here:

https://community.qlik.com/t5/Qlik-Design-Blog/Let-s-Dissect-the-Qlik-Engine-API-Part-4-Hypercubes/b...

clondon
Contributor II
Contributor II
Author

Thank you for the link to some explanatory documentation.  I was having trouble figuring out how to do that with the reference docs.

I currently was able to do a work around by creating a session app with a custom load script that had the filters applied.  Would you recommend one way over another?

Øystein_Kolsrud
Employee
Employee

Modifying the script and reloading the app should definitely give you the result you are looking for, but that's quite an expensive way to do it, at least if the app is large. But just how expensive totally depends on your app, so if that solution works for you, then I'd say its just fine!