Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
venturahl
Partner - Contributor III
Partner - Contributor III

Variables in Load Scrip - How to do it in Qlik Sense

Hello,

I'm having a problem when I try to create a variable with calculations and set anaysis in load script.

I've an huge expression (250 lines and 8000 characters) that I can't finished it because i've no space to do it and i need to do it in load script.

How can I do it in Qlik Sense?

My expression in front end is:

Sum({<DateNum={">=$(=$(vInitialDate))<=$(=$(vFinalDate))"},COD_RUB_DR = {'RES_SUBEXP'}>}MTR_SALDO_FINAL)

where

$(vInitialDate) ---> SET vInitialDate= num(MakeDate(year(today()),1,1));


$(vFinalDate) ---> SET vFinalDate= num(MonthEnd(AddMonths(Today(),-1)));



I've done in load Script like this:


SET vTeste = '(Sum({<DateNum={">=$((vDataIniSemSelec))<=$((vDataFimMesAntSemSelect))"}, COD_RUBRICA_DR = {"RES_SUBEXP"}>}MTR_SALDO_FINAL))';


Can anyone help me with this??


Best regards,


Helga

6 Replies
swuehl
MVP
MVP

I believe the dollar sign expansion will cause QS to immediately replace the variables in your script, which is not what you want.

You would need to use a kind of replace approach or a string concatenation or better use an external excel file to store your variables.

edit:

For example:

qlikfix.com/2011/09/21/storing-variables-outside-of-qlikview/

venturahl
Partner - Contributor III
Partner - Contributor III
Author

Hello again,

I've try it and doesn't work =(

swuehl
MVP
MVP

You have tried exactely what?

ziadm
Specialist
Specialist

Hi Try to enclose the variables with a single quote character

Sum({<DateNum={">=$(='$(vInitialDate)')<=$(='$(vFinalDate)')"},COD_RUB_DR = {'RES_SUBEXP'}>}MTR_SALDO_FINAL)

Also

use Let instead of Set

Let  vInitialDate= num(MakeDate(year(today()),1,1));

Hope this work ..

venturahl
Partner - Contributor III
Partner - Contributor III
Author

Hello again...

I've try lots of things and the result is the same.... nothing...

This result ignores the set analysis and returns me the sum of the metric..

any sugestion?

Thanks

venturahl
Partner - Contributor III
Partner - Contributor III
Author

Hello,

The solution is:

You Cannot use single quotes ('') and quotation marks ("") in the set analysis!

LET vRES_VESRPRS_BRT ='(Sum({<Year=, Month=, DateNum={">=' & chr(36) & '(=' & chr(36) & '(vInitialDate))<=' & chr(36) & '(=' & chr(36) & '(vFinalDate))"}, COD_RUB_DR = {RES_VESRPRS_BRT} >}MTR_SALDO_FINAL))';