Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Customer13
Contributor
Contributor

How to calculate previous month of MMM YYYY selected or other date type fields

Morning all,

I've got a calendar filter which is defined as 'MMM YYYY' eg:  Jan 2019.

How do I calculate previous month selected of that field which would be Dec 2018?

I tried ; 

count({$<[Month Year]={"=$(Month),-1)"}>)[case_id])

but doesn't appear to work.

 

I have also got [Date] which is dd/mm/yyyy, [Month] full month name and [Year]  yyyy fields if I would be better off using those instead?

I have tried with [Month]

[Month]={$(Addmonths([Month])-1)} but the expression still doesn't work.

Any help is much appreciated.

 

Labels (1)
4 Replies
tresesco
MVP
MVP

Try like:

count({$<[Month Year]={'$(=Date(AddMonths(Date#([Month Year], 'MMM YYYY'),-1),'MMM YYYY'))'}>)[case_id])

Customer13
Contributor
Contributor
Author

For some strange reason it doesn't work.

I'm trying to understand how qlik sense cloud works when wanting a previous criteria of the criteria selected so will try out the [Month Counter].  This is basically 1430 = Feb 2019,  1431 = March 2019.

I have tried;

With [Month Counter] as filter and selected 1431,

count({$<[Month Counter]={$[Month Counter]-1}>}[case_id]

 

but still no luck.  Surely this should be easier to make an expression of?

Thanks

tresesco
MVP
MVP

Try to share a sample app to work on.

Kashyap_R
Partner - Specialist
Partner - Specialist

Hi

Try this

count({$<[Month Counter]={"$(=max([Month Counter])-1)"}>}[case_id])

or

count({$<[Month Year]={"$(=Date(AddMonths(Date#(max([Month Year]), 'MMM YYYY'),-1),'MMM YYYY'))"}>)[case_id])

Hope this helps

Thanks

Thanks and Regards
Kashyap.R