Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Storing a Value of a Set analysis expression in a Variable

Hi Guys,

I am new to Qlik and struggling with storing  a set analysis expression's value in a variable.

I want to store below expression's value in a variable so that i can use that further for some calculations.

Min({< Data_Period = {'Weekly'},Formatted_Date = {'>$(=$(vSelectedWeek))'}>} Date,2)

The above expression works fine if i use it in a text box on a sheet tab. However, it is not working if i try to store its value in a variable and use that variable.

Set vW1 = Min({< Data_Period = {'Weekly'},Formatted_Date = {'>$(=$(vSelectedWeek))'}>} Date,2);


Here  vSelectedWeek  is being calculated as follows:


  Set vSelectedWeek = Date(Weekstart(Only(BaseData_Date)),'dd/MM/YYYY');


Please advise if i am doing anything wrong or is there any other way around to achieve the same?

Thanks in advance.

7 Replies
sunny_talwar

So $(vW1) in a text box isn't working? Do you have a equal sign before Min in the Variable Overview?

Not applicable
Author

Yes, =$(vW1) is not working in text box.

Not applicable
Author

If i write

=vW1

in a text box (to check if it is returning the correct value for vSelectedweek), It returns:

  Min({< Data_Period = {'Weekly'},Formatted_Date = {'>'}>} Date,2);

looks like it is not able to calculate the variable vSelectedWeek. dont know how can i make it return the correct value?

sunny_talwar

What about this:

=$(=vW1)

If it still doesn't work, would you be able to share a sample?

reddy-s
Master II
Master II

hi Aditya,

Making use of 2 equal to signs should solve your issue and works the same in both Qlikview and Sense.

Check this document for more deeper insight:

The Magic of Variables

Not applicable
Author

Hi Sangram,

As per your suggestion, i tried below expression:

Set vW1 = = Min({< Data_Period = {'Weekly'},Formatted_Date = {'>$(=$(vSelectedWeek))'}>} Date,1);

and it is not working.

Not applicable
Author

Hi Sunny, it is not working.