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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
ferha_jafri
Partner - Creator III
Partner - Creator III

Values of variable differ at script level and in text box

Hello Everyone,

I am facing an issue I am using a variable at script as SET Var1=sum({$<Date={">=$(Date(Max(Date)-7))<=$(=Max(Date))"}>}Mencount)

when I am using this expression in text box I am getting 10.5 and if I am using the variable directly into text box as $(Var1) I am getting 12.6 ,not able to understand why???Please help in understanding this.

Thank you

Regards

Ferha

8 Replies
sunny_talwar

Not sure why you would get different results. Would you be able to share your application or a sample?

vardhancse
Specialist III
Specialist III

No chance of getting different value, once can check the expression

svenkita
Creator II
Creator II

could you share the sample application.

normally there should not be a difference in the answers.

do you have alternate states in the application. then the values could differ depending on the state in which the formula is.

Not applicable

Hi,

Its preferable to use 'num' of date field in the variable, and convert the variable into date after variable is evaluated.

Try this.

SET Var1=sum({$<num(Date)={">=$(Date(Max(num(Date))-7))<=$(=Max(num(Date)))"}>}Mencount)

and use the variable as date(Var1)

ferha_jafri
Partner - Creator III
Partner - Creator III
Author

the exp

Var1=sum({$<Date={">=$(Date(Max(Date)-7))<=$(=Max(Date))"}>}Mencount)  gives correct value everywhere but if I divide this variable by 13 in script this is not getting reflected in the calculation although if write $(Var1)/13 in the front end it is giving the correct value.

ferha_jafri
Partner - Creator III
Partner - Creator III
Author

why this is happening not understand...

sunny_talwar

Are you doing it like this?

SET Var1=sum({$<Date={">=$(Date(Max(Date)-7))<=$(=Max(Date))"}>}Mencount)/13 and then $(Var1) doesn't seem to give the right result????

ferha_jafri
Partner - Creator III
Partner - Creator III
Author

Right