Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to Get Prev Month Value

Hi All,

I need to get Previous Month Value when i make a selection, but struggling to get it right?

E.g if i select May on a list box it must show me values for April.

like -1

i Tried:

=sum({<Dates={'>=$(=only(Dates)-2)<=$(=only(Dates))'}>}Sales)

and

=sum( {$<Year = {$(=Only(Year)-1)}>} Sales )

im i missing something in here?

Regards:

Thabiso

Labels (1)
11 Replies
Not applicable
Author

Hi SunIndia, yours it gives me current month Selected thou i need Previous month from that selected Month.

if on my listbox i select March, it must calculate for February.

Thanks

sunny_talwar

Try this expression:

=Sum({<Dates = {"$(='>=' & Date(AddMonths(MonthStart(Max(Dates)), -1), 'YYYY-MM-DD') & '<=' & Date(MonthEnd(Max(Dates)), 'YYYY-MM-DD'))"}, MonthDate = >}Sales)

Capture.PNG

Attaching the qvw for your review purposes.

Best,

Sunny