Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Everyone,
Can anyone help me in understanding the functionality of variable when we declare the in script and in variable overview.
Thank you
Regards
Ferha
You need what is called 'delayed expansion' as you only want the $() expansion taking place when the variable is used later in the front end. Although Set= does not evaluate the expression, the $() expansion occurs before the Set operation. To delay the expansion, you can use:
SET Var1='Sum({<Date={">$' & '(=Date(Max(Date)-7, DD/MM/YYYY'))<=$' & '(=Date(Max(Date), DD/MM/YYYY'))"}, Week=p(Week)>} Data)';
Edit: corrected as Peter pointed out, as well as correcting for Notepad++ mangling the single quotes:
Let Var1='Sum({<Date={">$' & '(=Date(Max(Date)-7, ''DD/MM/YYYY''))<=$' & '(=Date(Max(Date), ''DD/MM/YYYY''))"}, Week=p(Week)>} Data)';
Hi
Script:
Generally, we used to store the QVD path or file path in variable in script level.
We can also used to store the maximum or minimum date in order to generate the master calendar.
Let vMaxDate = Peek('MaxDate',0,'DateTemp');
We can able to remove the script variable like
Let vMaxDate = ;
UI:
We can used to store any color, expression, Currency conversation.
And also, we can use in "InputBox" or any condition.
Hope it helps to understand.
Hi Ferha,
Very Simple, When we write variable in script level we can edit and when we go for variable overview we can't edit which is our updated requirement on variable like:
Variable Name.
Ramya.
If the variable is defined only in the variable overview, and you need to recover the qvw by using a no-data load, or by restoring it from version control, then you will lose the value/definition of the variable as the variable contents are considered to be data. Therefore I always define important variables in script - this includes expression variables and state variables.
If a variable is only required for the script, and never in the front end, then if it is first defined in the script and set to null before the end of the script, it will not appear in the variable overview when the script completes.
My issue is when I am declaring a variable as
SET Var1=Sum({<Date={">$(=Date(Max(Date)-7,'DD/MM/YYYY'))<=$(=Date(Max(Date),'DD/MM/YYYY'))"},Week=p(Week)>}Data) in script then dates are not filtering in the range this expression in the script is taking all the dates ,althogh when I am declaring this variable in variable overview it is giving the correct date range ,why this is happening????
Hi,
Here you need to replace $ with some other sign, say @.
After in your expressions you should you $-sign expansion, like =$(ReplaceSring(Var1,'@','$')). Not sure whether the syntax is correct, but in general this is what can help.
Best regards,
Maxim
Maxim is right.
$-sign substitution works everywhere, even in the right-hand part of a SET statement. What happens in your SET statement is that both $(=Date(Max(Date),'DD/MM/YYYY')) and $(=Date(Max(Date)-7,'DD/MM/YYYY')) are immediately evaluated in your script and replaced by the outcome of the expressions even before the SET statement is executed.
Note that this is the only way you can calculate values in the right-hand part of a SET statement, which is otherwise defined as different from a LET statement because of not executing the right-hand part at all... This is a nice exam/interview question
Peter
You need what is called 'delayed expansion' as you only want the $() expansion taking place when the variable is used later in the front end. Although Set= does not evaluate the expression, the $() expansion occurs before the Set operation. To delay the expansion, you can use:
SET Var1='Sum({<Date={">$' & '(=Date(Max(Date)-7, DD/MM/YYYY'))<=$' & '(=Date(Max(Date), DD/MM/YYYY'))"}, Week=p(Week)>} Data)';
Edit: corrected as Peter pointed out, as well as correcting for Notepad++ mangling the single quotes:
Let Var1='Sum({<Date={">$' & '(=Date(Max(Date)-7, ''DD/MM/YYYY''))<=$' & '(=Date(Max(Date), ''DD/MM/YYYY''))"}, Week=p(Week)>} Data)';
I think Jonathan means:
LET Var1='Sum({<Date={">$' & '(=Date(Max(Date)-7, DD/MM/YYYY'))<=$' & '(=Date(Max(Date), DD/MM/YYYY'))"}, Week=p(Week)>} Data)';
LET is not working it is giving an error message..and SET is giving null values when I writing $(Var1) in pivot table.