Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Live chat with experts, bring your API Integration questions. June 15th, 10 AM ET. REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
tuxo9999
Contributor II
Contributor II

Show last 6 months when selecting

hello,

i would like to show the last 6 months when selecting a date.

date is my dimension and its format is yyyymm

sales is an expression

sum({1<date={'>=$(=AddMonths(Max(date),-5)) <=$(=(Max(date)))'}>}sales)

it is not working and i do not understand why.

i hope you can help me.

1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

When ever we deal with dates from excel we need to convert them to proper dates and work on them, that is how i do personally else things wont work properly. So, i have created my own excel sheet and worked on it. I have also created couple of variables for ease. Just press ctrl+alt+v to view them. Please find attached the excel sheet that replicates your data and sample file i worked on. Let me know if this is what you are looking for?

View solution in original post

9 Replies
vishsaggi
Champion III
Champion III

1 is the identifier in your set to ignore current selections.

Try removing 1 and select date and see if you getting any results?

= sum({<date={ ' >= $(=AddMonths(Max(date),-5)) <= $(=Max(date)) ' }>} sales)

tuxo9999
Contributor II
Contributor II
Author

not working

vishsaggi
Champion III
Champion III

Try this

= sum({<date={ " >= $(= Date(AddMonths(Max(date),-5))) <= $(=Max(date)) " }>} sales)


OR


= sum({<date={ " $(= '>=' & AddMonths(Max(date),-5))  & '<=' & Max(date)) " }>} sales)


Can you share a sample app if possible?

tuxo9999
Contributor II
Contributor II
Author

mm i think that date is making it wrong.

¿it is always my dimension ?

tuxo9999
Contributor II
Contributor II
Author

here i attached you some sample data

vishsaggi
Champion III
Champion III

Can you send me correct dates, when i used max date i got 210607 is this correct ? If i do addmonths -5 it is giving 210602 which is not there in the data.?

tuxo9999
Contributor II
Contributor II
Author

here you have with different data.

vishsaggi
Champion III
Champion III

When ever we deal with dates from excel we need to convert them to proper dates and work on them, that is how i do personally else things wont work properly. So, i have created my own excel sheet and worked on it. I have also created couple of variables for ease. Just press ctrl+alt+v to view them. Please find attached the excel sheet that replicates your data and sample file i worked on. Let me know if this is what you are looking for?

View solution in original post

tuxo9999
Contributor II
Contributor II
Author

it works fine. thank you