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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Ajay_S1
Contributor II
Contributor II

Get all values from field.

Hi,

I have embedded Qlik charts in my mashup project using the <qlik-embed> component. I need to apply an initial selection when the mashup loads.

The requirement is to dynamically determine the highest (latest) value from a field and use it as the initial selection. For example, if the field is Year and it contains values such as 2022, 2023, 2024, 2025, and 2026, I need to identify the maximum value (2026) at runtime and apply it as the initial selection when the mashup opens.

Labels (4)
3 Replies
TheLazyDeveloper
Contributor III
Contributor III

You could have a dynamic bookmark that is set for the latest year and apply that bookmark to your mashup/code. Similar process we have in place atm. 

Chanty4u
MVP
MVP

Hi

Create this in  qliksense script 

If(Year = Max(TOTAL Year), 1, 0) as LatestYearFlag

Then your mashup only needs to select LatestYearFlag = 1, avoiding the need to retrieve and compare field values in JavaScript.

Ajay_S1
Contributor II
Contributor II
Author

Hi,

I tried this approach in my project. In the load editor, I created a new field called LatestYearFlag using the following condition:

IF(Year(DateNum) = Year('$(vMaxDate)'), 1, 0) as LatestYearFlag

In my mashup, I applied the initial selection LatestYearFlag = 1. The LatestYearFlag field is selected successfully. However, the actual Year field is not automatically selected with the latest year value.

In the Year field, I can see that all years except the maximum year are grayed out, which indicates the association is working. However, the latest year itself is not shown as a selected value (green). Is there an additional step required to make the Year field itself become selected?