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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can you explain to me this expression:

I have this expression in a straight table:

Sum({$<Year={$(=Only(Year)-1)}>}  Sales)

I cannot get this syntax (the underline one)

Thanks in advance

1 Solution

Accepted Solutions
swuehl
MVP
MVP

$(=Only(Year)-1) is a dollar sign expansion, so it will evaluate the expression contained and it will be replaced with the result before the sum(... Sales) is evaluated.

Only(Year) will return the possible value from field Year, but only if there is only one possible value (i.e. you have actively selected one year or limited to one possible by selecting on other fields). You could also use max(Year) to always get a value returned, though results are different to only(year) if there are multiple possible values.

Then you deduct 1 from the Year value, giving the year number prior the possible value.

So if today's year 2011 is the only possible value, it will expand to

Sum({$<Year={2010}>}  Sales)

Hope this helps,

Stefan

View solution in original post

2 Replies
Anonymous
Not applicable
Author

if variable Yaer = 2011   is the sum of sales for year 2010

swuehl
MVP
MVP

$(=Only(Year)-1) is a dollar sign expansion, so it will evaluate the expression contained and it will be replaced with the result before the sum(... Sales) is evaluated.

Only(Year) will return the possible value from field Year, but only if there is only one possible value (i.e. you have actively selected one year or limited to one possible by selecting on other fields). You could also use max(Year) to always get a value returned, though results are different to only(year) if there are multiple possible values.

Then you deduct 1 from the Year value, giving the year number prior the possible value.

So if today's year 2011 is the only possible value, it will expand to

Sum({$<Year={2010}>}  Sales)

Hope this helps,

Stefan