
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Last 5 records from Each Month
I'm trying to get a sum in Qlik Sense that will be displayed in a bar chart
I need to show, by month, the last 5 records in the data based on each month (but not necessary from that month). I'm thinking it would need to include a combination of an aggr and recno but that's a guess.
For example:
Date | Month | ID | Amount |
1-Jan | January | 1 | 10 |
12-Jan | January | 2 | 20 |
13-Jan | January | 3 | 30 |
18-Jan | January | 4 | 40 |
19-Jan | January | 5 | 50 |
29-Jan | January | 6 | 60 |
11-Feb | February | 7 | 70 |
12-Feb | February | 8 | 80 |
17-Feb | February | 9 | 90 |
1-Mar | March | 10 | 100 |
3-Mar | March | 11 | 110 |
8-Mar | March | 12 | 120 |
9-Mar | March | 13 | 130 |
1-Apr April
January would be the sum of ID 6,5,4,3,2
February would be the sum of ID 9,8,7,6,5
March would be the sum of ID 13,12,10,9
April would also be the sum of ID 13,12,11,10,9
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brandon,
It has become interesting to try to solve your task. I propose to solve the task using the data island, transferring all the calculations to the script. In the attached file QVF, as an variant, an implementation example. All comments are in script code.
I will be glad if I could help you.
Regards,
Andrey


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brandon,
It has become interesting to try to solve your task. I propose to solve the task using the data island, transferring all the calculations to the script. In the attached file QVF, as an variant, an implementation example. All comments are in script code.
I will be glad if I could help you.
Regards,
Andrey

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Brandon,
In this case your ID keeps going up together with the date. When you select a date/month, you can use MAX(ID) to find out what your highest ID is or better said, your starting point. At this point you can add the 4 ID's previous to this point and add them to your MAX(ID) and you will have the 5 highest ID's.
Hope this works.
