Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set expression being ignored

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.

13 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

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)


talk is cheap, supply exceeds demand
Not applicable
Author

Try this expression

=sum({1} {<DisplayRate,Class>} DisplayRate*Price/ExchangeRate)

Not applicable
Author

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.

Not applicable
Author

This gives "no data to display"!  But surely since there is only one value selected, Only() should be identical whatever the set identifier?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Can you post a small qlikview document that demonstrates the problem?


talk is cheap, supply exceeds demand
Not applicable
Author

It's attached to the initial entry.

swuehl
MVP
MVP

Kind of strange.

I got it working using a variable vRate = DisplayRate

Not applicable
Author

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?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

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.


talk is cheap, supply exceeds demand