Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
cedfoning
Creator
Creator

Last 2 previous months on selection

Hello, please help, i have an issue. 

I have the following data. The user selected the month of February. 

Upon selection, he has the following data. 

 

  Stock at
20240131
Stock at
20240229
Code    
1 8 732,000 7 859,000
2 6 395,000 5 610,000
3 1 399,000 1 186,000
4 2 154,000 1 893,000
5 6 731,000 5 711,000

 

I want to implement this table in Qlik sense. 
Each time the user selects a month, lets say 202402, we must have the result of the last day of the month selected on one column and the last day of the previous month on the other column.

Labels (4)
4 Replies
anat
Master
Master

assuming you data source data like below:

 

id month sal
1 20230101 100
2 20230115 10
3 20230131  

table1:

load id,month,sal from table;

VCM=monthend(max(month))

VPM=monthend(addmonths(max(month),-1))

curent month:sum({<month={'$(VCM)'}>}sal)

Pre month:sum({<month={'$(VPM)'}>}sal)

cedfoning
Creator
Creator
Author

How can you get a monthend of a month ? 
is it not a monthend of a date ?

 

The rule is : when the user selects a month, whe should have the sum of sales of the last day of the month selected

cedfoning
Creator
Creator
Author

Ok i see. 
i tried but it's not weekend. 
When i select a month in a filter, your script doesn't work. 

  Stock au
20240229
Stock au
20240303
Code    
1 8 732,000 7 859,000
2 6 395,000 5 610,000
3 1 399,000 1 186,000
4 2 154,000 1 893,000
5 6 731,000 5 711,000

 

In the dataset above, the user selected the month of february. 
the results shows then last day of the month selected and the last day of previous month depending on the selection