Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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.
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.
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?