Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Community,
I have a simple problem that i can't resolve.
I want to put in my script the declaration of a variable that includes another variable:
Set vCurrentWeek = "max({<[Calendar-Year]={$(v_MaxYear)}>} [Calendar-Week])";
And i want that when i recompile this script, in the variable declaration appear the $(v_MaxYear) literally, not expanded with the value.
Result:
Expected:
It's posible?
Thanks in advance,
Ivan.
Hi Ivan, to avoid that you can replace the $ by another symbol, and load it using 'LET' and Replace(). Check this answer by Marcus Sommer: Re: Setting a variable in script...
And as a bonus, from the same author: Variables
In your case it can be:
Let vCurrentWeek = Replace('max({<[Calendar-Year]={#(v_MaxYear)}>} [Calendar-Week])', '#', '$');
The same can be used with simple quotes (if needed):
Let vCurrentWeek = Replace(Replace('max({<[Calendar-Year]={|#(v_MaxYear)|}>} [Calendar-Week])', '#', '$'), '|', Chr(39));
Hi Ivan, to avoid that you can replace the $ by another symbol, and load it using 'LET' and Replace(). Check this answer by Marcus Sommer: Re: Setting a variable in script...
And as a bonus, from the same author: Variables
In your case it can be:
Let vCurrentWeek = Replace('max({<[Calendar-Year]={#(v_MaxYear)}>} [Calendar-Week])', '#', '$');
The same can be used with simple quotes (if needed):
Let vCurrentWeek = Replace(Replace('max({<[Calendar-Year]={|#(v_MaxYear)|}>} [Calendar-Week])', '#', '$'), '|', Chr(39));
Its called 'deferring the $ expansion'.
Set vCurrentWeek1 = max([Calendar-Year])
Set vCurrentWeek = Sum({<[Calendar-Year] = {"=$(vCurrentWeek1)"}>}Sales)
Good Luck