Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Aarya_Kankipati
Contributor III
Contributor III

Second Top3 values in field

Year_Week Product
2024-02 56
2024-01 26
2023-52 58
2023-51 79
2023-50 47
2023-49 44

 

I have a year week field as above; I created a variable equal to filed.

If I want to select 202402, it should give 202401, 202352, 202351 like past 3 weeks.

 

I tried this but it taking 202401, 202400, 202399
sum ({$ <YW={">=$(=max(YW)-3)"}>} product)

 

this it to get 2023-52, but its giving 202400

sum ({ <YW={'$(=max((V_YW)-2))'}>} product)

1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

create a sort_order / serial numbers during data load

 

TEMP:
Load Year_Week,Product,RECNO() AS SR_NO inline [
Year_Week,Product
2024-02,56
2024-01,26
2023-52,58
2023-51,79
2023-50,47
2023-49,44
];

 

then use

SUM({<SR_NO={">=$(=Max(SR_NO)-2)<=$(=Max(SR_NO))"}>}Product)

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

2 Replies
vinieme12
Champion III
Champion III

create a sort_order / serial numbers during data load

 

TEMP:
Load Year_Week,Product,RECNO() AS SR_NO inline [
Year_Week,Product
2024-02,56
2024-01,26
2023-52,58
2023-51,79
2023-50,47
2023-49,44
];

 

then use

SUM({<SR_NO={">=$(=Max(SR_NO)-2)<=$(=Max(SR_NO))"}>}Product)

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Aarya_Kankipati
Contributor III
Contributor III
Author

I have more data. every week its loading. And I changed from string to integer by removing "-". To make it easy

At current, its 202403 and last value is 202101. 

202402,56
202401,26
202352,58
202351,79
202350,47
202349,44 
..
..
202101,28