Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis: show the last value of the last year

Hi Community!

My table is the following:

  

YEARMONTHDATEVALUE
2015630/06/201538
2015531/05/201537
2015430/04/201530
2015331/03/201533
2015228/02/201533
2015131/01/201514
20141231/12/201452
20141130/11/201448
20141031/10/201449
2014930/09/201446
2014831/08/201447
2014731/07/201445
2014630/06/201449
2014531/05/201453
2014430/04/201457
2014331/03/201460
2014228/02/201473
2014131/01/2014100

  
And I'm trying to display in a bar chart a double expression:

- the first one must show the last value of the current year: OK, I managed to get it by using the function max(DATE) within the set analysis.

- the second one must show the last value of the last year in order to compare with the current one (38) with the last average of the last year (52).

Do you know how could I obtain the max(DATE) of the max(YEAR-1)?

Thanks in advance to all of you!

Regards,

Vincent

16 Replies
Not applicable
Author

I wish I could convince my user in order to oblige him to do this, but unfortunately, he did not accept this proposal 😞

MK_QSL
MVP
MVP

You can use as below

Dimension

YEAR

Expression

=FirstSortedValue({<YEAR = {"<=$(=MAX(YEAR))>=$(=MAX(YEAR)-1)"}>}VALUE,-MONTH)

Hope this what you are looking for !

Not applicable
Author

Unfortunately, no, because I have more than one value for the same month in some cases (I've tried to add a SUM to the expression, but it didn't work

(=FirstSortedValue(sum({<YEAR = {"<=$(=MAX(YEAR))>=$(=MAX(YEAR)-1)"}>}VALUE),-MONTH)

Thanks a lot for your help!

MK_QSL
MVP
MVP

Provide data with more than one value for the same month along with your expected output.. I will try.!

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

For Current Year:

=Sum({<YEAR =, DATE={'$(=Date(Max(DATE)))'}>}VALUE)


For Previous Year:

=Sum({<YEAR =, DATE={"$(=Date(Max({<YEAR={'$(=(Max(YEAR) - 1))'}>} DATE)))"}>}VALUE)

Hope this helps you.


Regards,

Jagan.


Not applicable
Author

OMFG! It works! Thanks a lot Jagan!

jozisvk11
Creator
Creator

Hello, I have problem with set analyse. I want to filter only values, where is the rows max. I have this, but it is not good.

Sum ({<[Rank of line] = {"$(=max([Rank of line])"} >} [Sum of income]). Thanks for helping me.

Here is my table.

ID Purchase          Row          Income  

N01                      1                  200

N02                      1                  50
N02                      2                  70

N02                      3                  60

N03                      1                  10

N03                      2                  35

N04                      1                  10

N04                      2                  40

N04                      3                  60

N04                      4                  90

N05                     1                  20

Set Analayse should choose me only this table.

ID Purchase          Row          Income  

N01                      1                  200

N02                      3                  60

N03                      2                  35

N04                      4                  90

N05                      1                  20