Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Damian-Matthews
Contributor
Contributor

Qlik Embedded - Initial Selections issues

Hello everyone, 

I'm currently exploring the world of Qlik Embedded, and after some trial and error, I've been able to successfully embed my clients App/sheets/objects into a little dummy Angular project. 

The problem I now face however, is attempting to apply a selection, making use of the qlik-initial-selections object. More info can be found on this object here: Set analytics selection state on qlik-embed | Qlik Developer Portal

There are currently 2 issues I currently face. 

  1. Specifying a selection against a date or a numeric field
  2. Specifying a function against a field 
    1. ie: <field name="EventDateNum" values="=EventDateNum>'20241001'"></field>
    2. ie: <field name="EventDate" values="=num(Date(Floor(EventDate)))>'45207'"></field>

Selections made against text fields work, with static values. No functions can be used in the values property. 

Example code implemented: 
Note that EventDateNum is the Date field with the dashes removed. 


<qlik-initial-selections app-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx">
<field name="Network Name" values="My Random Network"></field>
<field name="EventDateNum" values="=EventDateNum>'20241001'"></field>
</qlik-initial-selections>

<qlik-embed
ui="analytics/selections"
app-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx"
></qlik-embed>

<qlik-embed
ui="analytics/sheet"
app-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx"
object-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx"
></qlik-embed>

Thanks in advance for any suggestions on how to correctly implement an initial selection on numeric fields.

Labels (2)
1 Solution

Accepted Solutions
Damian-Matthews
Contributor
Contributor
Author

Hi @Jeffrey_Goldberg, thank you very much for reaching out and pointers (in the right direction!) 
With your observation, I actually opened the imported JS file and searched for the initial selection functions, and this is what I found. 

There is a function named fieldElementsToFieldSelections within the embed-web-components folder in the index.js file. This function checks for a few different fields, namely; name, state, values, match. 

With your direction, I noted that I'd need to use match in place of search, and then apply the expression required. This now works as expected on all data types, utilizing the standard Qlik operators. IE, * as a wildcard, > as greater than, < as less than, etc. 

An additional note I'd like to add, that I noticed while in the index.js file, is there are additional properties that can be applied to the component being clear-all (boolean that determines if the existing selections should be cleared on re-initialization) and bookmark (bookmark object that contains either a data-id or bookmark-id property with it's value) 

The use case I have now implemented:

<qlik-initial-selections app-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx" clear-all="true">
<field name="Network Name" values="My Random Network"></field>
<field name="Event Date" match=">08/01/2023"></field>
</qlik-initial-selections>

 

View solution in original post

4 Replies
Jeffrey_Goldberg
Employee
Employee

Hi @Damian-Matthews , I see what you are trying to do and I'm uncertain if it's possible to perform the operation you are trying to do on a numeric field with initial-selections. I'll have a look and if not possible, I'll add it to the backlog as an enhancement.

Another way you could do an initial selection, albeit a little more coding, is to use qlik-api to connect to the same session, get a field and make a selection.

Working on some other tutorials right now, but if you need a code sample I can probably whip one up.

Thank you for using qlik-embed and qlik-api.

 

Jeff G

Jeffrey_Goldberg
Employee
Employee

@Damian-Matthews , here is something to try.

In the initialAppState module there is this type:

type FieldSelectionState = {
    name: string;
    state?: string;
    values?: FieldValue[];
    search?: {
        match: string;
    };
};

 Notice the search property? Instead of supplying values, use a search attribute and add your query there. so something like this:

<qlik-initial-selections app-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx">
<field name="Network Name" values="My Random Network"></field>
<field name="EventDateNum" search="{match:'\>20241001'}"></field>
</qlik-initial-selections>

 I think this might work. You may have to play around with the match part. Basically when providing the search part you're invoking this method in qix: https://qlik.dev/apis/json-rpc/qix/field/#select

 

Damian-Matthews
Contributor
Contributor
Author

Hi @Jeffrey_Goldberg, thank you very much for reaching out and pointers (in the right direction!) 
With your observation, I actually opened the imported JS file and searched for the initial selection functions, and this is what I found. 

There is a function named fieldElementsToFieldSelections within the embed-web-components folder in the index.js file. This function checks for a few different fields, namely; name, state, values, match. 

With your direction, I noted that I'd need to use match in place of search, and then apply the expression required. This now works as expected on all data types, utilizing the standard Qlik operators. IE, * as a wildcard, > as greater than, < as less than, etc. 

An additional note I'd like to add, that I noticed while in the index.js file, is there are additional properties that can be applied to the component being clear-all (boolean that determines if the existing selections should be cleared on re-initialization) and bookmark (bookmark object that contains either a data-id or bookmark-id property with it's value) 

The use case I have now implemented:

<qlik-initial-selections app-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx" clear-all="true">
<field name="Network Name" values="My Random Network"></field>
<field name="Event Date" match=">08/01/2023"></field>
</qlik-initial-selections>

 

Jeffrey_Goldberg
Employee
Employee

@Damian-Matthews ,

Great to read you have it working. I acknowledge the feedback. We are constantly striving to improve our documentation and reference.

So excited to see you using qlik-embed!

Cheers,


Jeff G