Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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)

Anonymous
Not applicable
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?

Anonymous
Not applicable
Author

mm i think that date is making it wrong.

¿it is always my dimension ?

Anonymous
Not applicable
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.?

Anonymous
Not applicable
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?

Anonymous
Not applicable
Author

it works fine. thank you