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

Value for a specific data from Datasource

Hi,

      I have created a variable, which is a sum expression for some generic value set satisfying some condition.(Created using script)[  var1 = sum({$(=if( -- ))}) ]

      Now i want to create another variable from this existing variable, for which I want to check one more condtion,

           Var2 = $var1(PREVIOUS-YEAR = '2014')

       How can I do it??

11 Replies
Anonymous
Not applicable
Author

Hi

Is your variable     var1 is a  Year field ?

Anonymous
Not applicable
Author

No, its an amount field. Actually var1 shows sum of amount for current year+ previous year + etc.. 


My requirement is, in my selection if i am selecting current year, i want to set a variable with previous year amount. The name of my selection filter is 'Year'.

marcohadiyanto
Partner - Specialist
Partner - Specialist

Hi Bijoy,

Please read article https://community.qlik.com/blogs/qlikviewdesignblog/2015/10/12/why-is-it-called-set-analysis

I think set analysis can solve your problem.

Regards

Anonymous
Not applicable
Author

Hi

why do not try set analysis in Pivot table  ?? Assuming    'Year' for filter  field

previous year

sum({<Year={'$(=Year(Today())-1)'}>} Amount)


current year


sum({<Year={'$(=Year(Today()))'}>} Amount)


if you would like save this expressions in a variables ...



LET Vpreviousyear='sum({<Year={'&chr(36) & '(=Year(Today())-1)'}>} Amount)';

LET Vcurrentyear='sum({<Year={'&chr(36) & '(=Year(Today()))'}>} Amount)';










marcohadiyanto
Partner - Specialist
Partner - Specialist

LET Vpreviousyear='=sum({<Year={'&chr(36) & '(=Year(Today())-1)'}>} Amount)';

LET Vcurrentyear='=sum({<Year={'&chr(36) & '(=Year(Today()))'}>} Amount)';

try adding equal in your variable.

Anonymous
Not applicable
Author

Actually the amount field in the above statement is another variable in my case "$(Var_MIS_RoomExpense"??

fabs({<[SCENARIO.COD_SCENARIO] = {=$(Year_CurrentMIS)}>}{$(Var_MIS_RoomExpense)})

Anonymous
Not applicable
Author

fabs({<[SCENARIO.COD_SCENARIO] = {=$(Year_CurrentMIS)}>}{$(Var_MIS_RoomExpense)})


         it is not working for me actually

ToniKautto
Employee
Employee

It is extremely hard to answer a question like this without any data.

Can you please provide a small sample app file and explain what result you expect to see in the app object?