Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Show past 12 months

I need to show data for the past 12 months of the current date (including current month)

Currently, my dimension for my chart is a calculated dimension:

=date(MonthName([rcptdate]), 'MM-YY')

How do I only show the past 12 months?

1 Solution

Accepted Solutions
MayilVahanan

HI

Sum({<rcptdate={">=$(=timestamp(MonthStart(Today(),-12)))<=$(=timestamp(Today()))"}>}extcost)

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

14 Replies
MayilVahanan

Hi

=sum({<Date = {'>=$(=vVar1)<=$(=vVar)'}>}Sales)

vVar1

=AddMonths(Date,-12)

vVar

=AddMonths(Date,0)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
CELAMBARASAN
Partner - Champion
Partner - Champion

This can be done using set analysis

Example if ur date field is rcptdate and ur present expression is Sum(Sales)

Sum({<rcptdate={">=$(=MonthStart(today(),-12)))<=$(=Today())"}>} Sales)

If your requirement is based on the given date

Sum({<rcptdate={">=$(=MonthStart(vSelectedDate,-12)))<=$(=vSelectedDate)"}>} Sales)

vSelected date is a variable which has the date selected.

Not applicable
Author

Celam:

Where exactly do I put this?    If I put it in expression, it tells me "No data to display"

and my current expression was:

Sum(extcost)

Then, changing it using  your tip:

Sum({<rcptdate={">=$(=MonthStart(today(),-12)))<=$(=Today())"}>} extcost)

And I get "no data can be displayed"

Any ideas?

Not applicable
Author

Actually, I think I found the first issue:

I change the Today()  to Now()  and that seemed to get data to come back

It is, however, still giving me all data back, and not the past 12 months

CELAMBARASAN
Partner - Champion
Partner - Champion

Check the date format for both MonthStart(Today()) and your rcptdate field. Is it same?

Not applicable
Author

Yes, they are the same

CELAMBARASAN
Partner - Champion
Partner - Champion

Try this

Sum({<rcptdate={">=$(=MonthStart(today(),-12))<=$(=Today())"}>} extcost)

There is a typo mistake in braces

Not applicable
Author

That gives me "no data to display".    If I change Today() to Now() I get data, but all time data, not past 12 months

CELAMBARASAN
Partner - Champion
Partner - Champion

It will work. can you send me a sample?