Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I did found the following thread (Set Analysis - how to use variables inside set ... | Qlik Community) which deals with the problem I have.
Unfortunately, I could not figure out how it finally works. Here is my problem:
I have a variable (Calculation) with the following content:
Sum({<Product={$1}, Customer={$2}>} Sales)
I want to use this variable in a text box and display the summation value for two products (Product 1 and Product 2) at one customer (Customer 1).
Here is my problem: I am unable to pass two members to the parameter $1, however, if I just pass one product and one customer it works fine.
I tried the following syntax options in my textbox without success:
=$(Calculation('Product 1, Product 2','Customer 1)) ---> Just providing the list with single quotes
=$(Calculation('"Product 1", "Product 2"','Customer 1)) ---> Enclosing each product with a double quote
=$(Calculation('[Product 1], [Product 2]','Customer 1)) ---> Enclosing each product with brackets
=$(Calculation("'Product 1, Product 2'",'Customer 1)) ---> Using double quotes for the product parameter in total while enclosing each product with single quotes
I have no further idea how to make it work....
However, as mentioned if I just pass one product either Product 1 or Product 2 it works in two ways:
=$(Calculation('Product 1','Customer 1)) ---> Enclosing product in single quotes
=$(Calculation("Product 1",'Customer 1)) ---> Enclosing product in double quotes
Thanks for any help!
In your variable you have only two members but you are trying to pass three members (2 products and 1 Customer):
So if you want to pass two Product, please follow below steps:
1) Your variable (Calculation) expression should be as below:
Sum({<Product={$1,$2}, Customer={$3}>} Sales)
2) And your expression should be as below:
=$(Calculation(Product1,Product2,Customer1))
If you want to pass only one Product then give the following expression:
=$(Calculation(Product1,'',Customer1))
Hope this helps....
Yes, commas within the variable parameters are difficult - here you will find much background informations for it:
Re: variable with comma parameter
Beside them the following workaround which transferred a compound search-string might be the easiest way to handle your case:
Sum({<Product={'($1)'}, Customer={$2}>} Sales)
=$(Calculation("Product 1"|"Product 2","Customer 1"))
- Marcus
Hi Marcus,
I am sorry not having answered yet. I tried you proposal but it did not work. May it because of the spaces in the values that I am looking for?
Do you have a small sample app where you tried these things which I can learn from?
Thank you very much!
Best regards
Marcel
Hi Marcel,
for me it worked:
- Marcus