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: 
analovera91
Contributor
Contributor

Formula with variable

Hello,

I´m trying to change a value in a formula by a variable, to make this flexible, but the moment I include the variable in the formula this doesn´t work anymore.

This is the initial formula I´m using:

sum({<[Daily Index]={">0  <=615"}>}Value_OK)

However, when I use a variable instead of 615 (to make it dynamic) the formula gives a wrong number:

sum({<[Daily Index]={">0 <=$(vLastUpdateDailyIndex)"}>}Value_OK)

Please note that in the variable ‘LastUpdateDailyIndex’ we are trying to dynamically calculate an index as (Month*100 + DayNumber) to calculate across different years.

Example: 15th June, Index=615 (6*100 + 15)

The variables used seem to be working fine, these are the formulas:

vLastUpdateDailyIndex = month($(vLastUpdate))*100) + Day($(vLastUpdate)
vLastUpdate = max(if(Version='Actual_2021',[Posting Date],0))
 
Only the formula mentioned above is not working:
sum({<[Daily Index]={">0 <=$(vLastUpdateDailyIndex)"}>}Value_OK)
Is there something wrong in the syntax?
 
Thanks
1 Solution

Accepted Solutions
sunny_talwar

Try these

Sum({<[Daily Index] = {">0<=$(=vLastUpdateDailyIndex)"}>} Value_OK)

or this

Sum({<[Daily Index] = {">0<=$(=$(vLastUpdateDailyIndex))"}>} Value_OK)

View solution in original post

2 Replies
sunny_talwar

Try these

Sum({<[Daily Index] = {">0<=$(=vLastUpdateDailyIndex)"}>} Value_OK)

or this

Sum({<[Daily Index] = {">0<=$(=$(vLastUpdateDailyIndex))"}>} Value_OK)
analovera91
Contributor
Contributor
Author

Thanks a lot! The formula is working:

Sum({<[Daily Index] = {">0<=$(=$(vLastUpdateDailyIndex))"}>} Value_OK)