Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.02.89.41/Test_2D00_Creating-Group-Sample-20100411000.qvw]
Hi guys,
I am declaring the variable "vSalesByCurrency" into Document properties as:
If($(vCountYear)>3, Sum($(=Concat(SalesByCurrency))) * $(vYearFlag), Sum($(=Concat(SalesByCurrency))))
and then using it as an expression in Table1 as:
=$(vSalesByCurrency)
The question is: Is there any chance to declare and assign this variable just in the script?
I want to avoid declaring it in Document properties.
I've been trying several ways, but getting internal error...
see the attachment.
Thanks in advance for any help,
Aldo.
Certainly, you can declare and assign values to a variable from within the script.
The syntax is:
Let vMyStartDate = MakeDate(2009,12,10);
Alternately, you can use Set instead of Let. You can see the help file for the differences.
Hi man,
Thanks for answering.
I know how to declare a simple and assign a simple one, but getting hard with the example I post above...
Aldo.
The problem with the variable assignment in your example are 2:
a. You are using a set modifier - by using Sum($=<exp>). Set modifiers are not allowed inside the script
b. You are trying to sum a string; and then multiply a string with a number - Concat(SalesByCurrency) returns a string, and this is being summed up.
Hi Upendra,
Could you help to understand what's the meaning of:
$( =Concat(SalesByCurrency) )
Thanks,
Aldo.
Concat is an aggregate function, and should be used with Group By.
Concat creates a string (a seperator can be specified) that is made up of values in successive rows.
And $(=<exp>) is a set modifier, where you are trying to calculate the sum, but with a different criterion (the formula you gave is incomplete).
Ex. Sum ({$<Currency=$(=$(vCurrency))> Sales} will give Sales for the current selection, but only for the defined Currency.
Hi,
Instead of Dollar sign in script use this ' & Chr(36) & '
Thanks guys,
I will try using your suggestions.
Once I have the answer to the post, I will set it to solve.
Thanks a lot,
Aldo.