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

Set analysis as variable in Load statement

Hello,

I would like advice on Set analysis and variable in Load statement. I searched the community for a similar problem, but I couldn't find anything that would help me.

The idea is that I would like to insert the string (Set analysis) into a variable in the Load statement and then use it in an expression (for example a pivot table). In the attached QV example I put it in a Text object for the simplicity now.

However, calculating "set analysis = > count DATE lines per YEAR does not work for me: 

=count({$<DATE={"$(=Date(MakeDate(GetFieldSelections(YEAR),1,1),'D.M.YYYY'))"}>} YEAR)

a simple line with the constant: year = 2023 looks like this:

= count({$<DATE={2023}>} YEAR)

I think there is a problem with the GetItemSelections() when I SET it in the variable.
The resulting value is 0 and the result should be equal to 3 for year 2023.
I checked whether the same Set analysis entry works correctly, but by writing it directly (without a variable) into the text object as an expression - it works fine there, the result is correct = 3 for year 2023 (2 for year 2022, 1 for year 2021)

Please advise me how to write correctly the variable in the load statement?

PeterHCM_1-1662562012305.png

 

PeterHCM_0-1662561359497.png

 

Thanks.

Peter

Labels (1)
1 Solution

Accepted Solutions
Lisa_P
Employee
Employee

I found a link to another article that has a workaround by loading from an excel file ..

https://community.qlik.com/t5/QlikView-Documents/Managing-Variables/ta-p/1495738 

View solution in original post

4 Replies
Lisa_P
Employee
Employee

Here is the problem. This is what is stored in the variables:

Lisa_P_0-1662597837203.png

 

PeterHCM
Contributor II
Contributor II
Author

Thanks Lisa for your reply,
yes, you're right - that's a problem in the variable where the date function is defined = Date(MakeDate(GetFieldSelections(YEAR),1,1),'D.M.YYYY')

the variable that gets into the expression is = count({$<DATE={""}>} YEAR)
where I would like the date (defined formula) to be written there instead of ""

Please, does anyone know a trick how to write this variable correctly?
I spend a lot of time testing but still no solution 😞

Lisa_P
Employee
Employee

I found a link to another article that has a workaround by loading from an excel file ..

https://community.qlik.com/t5/QlikView-Documents/Managing-Variables/ta-p/1495738 

PeterHCM
Contributor II
Contributor II
Author

Thank you Lisa, very good suggestion to solve my problem...