Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a list of items with prices in different currencies, each item in a class which is used as the dimension. I want to display the totals by class in a selected display currency. And I want to do this with (A) the current selection {$}, and (B) the entire set {1}.
The load statements are as follows:
Data:
LOAD * INLINE [
Class,Item,Price,Currency
'Tech','TV',200,'GBP'
'Tech','VCR',100,'EUR'
'Tech','Speakers',400,'USD'
'Home','Sofa',800,'GBP'
'Home','Table',900,'EUR'
'Home','Rug',200,'USD'
'Garden','Swing',150,'GBP'
'Garden','Parasol',250,'GBP'
'Garden','Mower',300,'GBP'
];
Currencies:
LOAD * INLINE [
Currency,ExchangeRate
USD, 1.00
EUR, 0.90
GBP, 0.65
];
DisplayCurrencies:
LOAD * INLINE [
DisplayCurrency,DisplayRate
USD, 1.00
EUR, 0.90
GBP, 0.65
];
My expressions are respectively:
(A): DisplayRate*Sum(Price/ExchangeRate)
(B): DisplayRate*Sum({1}Price/ExchangeRate)
When I select different combinations of Class the first chart behaves as expected, displaying the selected dimensions.
But the second chart changes in synch with the first whereas I expect it to show all dimensions all the time.
If I remove the scalar DisplayRate from the second expression to become
Sum({1}Price/ExchangeRate)
then it displays all classes all the time, as I expect.
Is there some subtlety in set expressions that I have missed?
I am attaching my QVW file.
DisplayRate is also aggregated using the implicit Only() function since you didn't specify an aggregation function explicitly. Your expression is really Only(DisplayRate)*Sum(Price/ExchangeRate). To make that ignore selections as well you need to add the record set definition {1} to the Only() function too: Only({1}DisplayRate)*Sum({1}Price/ExchangeRate)
Try this expression
=sum({1} {<DisplayRate,Class>} DisplayRate*Price/ExchangeRate)
I don't understand the syntax of the inner {..}.
What I did try was
$(=DisplayRate)*Sum({1}Price/ExchangeRate)
and this worked.
So now I want to understand how dollar-sign expansions affect the logic.
This gives "no data to display"! But surely since there is only one value selected, Only() should be identical whatever the set identifier?
Can you post a small qlikview document that demonstrates the problem?
It's attached to the initial entry.
Kind of strange.
I got it working using a variable vRate = DisplayRate
Of course this is a contrived example to illustrate a difficulty I have found on a bigger data set. So I am interested in the principles of what works and why.
What is the avg() function doing that is different from just using a single-valued field? In another post to this thread I tried $(=DisplayRate) and this worked. I can use a constant scalar such as 0.5*Sum(...) so what type of entity can I use instead of the 0.5?
Yeah, I can understand why only({1}DisplayRate)*... wouldn't work. But only({<Class>}DisplayRate)*... should afaik. Perhaps the fact that the tables are not linked is causing the weirdness. As soon as I outer join DisplayCurrencies with the Currencies table the weirdness is gone. Of course the expression results are bogus after the outer join (though sum(distinct...) works). My conclusion: use data islands with care. They're inhabited by gremlins.