Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Is it possible.... by using set analysis

IMPORTANT: I have attached an example

I am really sorry because in these days I am bothering the community with Set analysis problems.... but then again is it possible to obtain this table:

YEARSALESSALES (YEAR- 1)
2009754-
20105754
2011305

Is it possible to obtain the previous values without modify the script (and WITHOUT using above or before)?

Thanks in advance

5 Replies
danielact
Partner - Creator III
Partner - Creator III

I can't think of a way to do it without changing the script.

If you can change the script a bit, an easy method would be to create another table which doesn't link to your data source.

Years:

Load Distinct Year as Year2

resident Data;

Then, in your chart, use Year2 as your dimension, and use the following expressions:

sum(if(Year=Year2,Sales))

sum(if(Year=Year2-1,Sales))

Not applicable
Author

Thanks Danielact, at the end I think this is the only way ....

Not applicable
Author

You could try this:

if(YEAR=2010,sum(total{$<YEAR={2009}>}SALES),if(YEAR=2011,sum(total{$<YEAR={2010}>}SALES)))

swuehl
MVP
MVP

I would also prefer using a small script change, or above(), but since you don't want this, you could do the same like suggested by danielact with an synthetic dimension. Please see attached.

I assume you want to learn how to do this with set analysis. Well, the set expression is evaluated once per chart, so you can't request the actual dimension value YEAR for a row and use it in your set expression.

You can create set expressions for each year, though and get the same results, but you lose the flexibilty (if you add more YEARs, this chart won't reflect it automatically).

Regards,

Stefan

johnw
Champion III
Champion III

I'd make script changes.  But if that's not allowed, here's a way to do what frankrezee was suggesting without hardcoding the dates.

$(=concat(distinct 'if(YEAR=' & YEAR & ',sum({<YEAR={' & (YEAR-1) & '}>} total SALES)',',',YEAR)&repeat(')',count(distinct YEAR)))