Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
ugurarslan
Creator
Creator

Current month, prior month

Dear all,

a very simple question where I struggle already for a few days.

For the current invoice month I use [Invoice Year Month]={'$Current_Month_YYYYMM)'}.

Question, how can I get prior month or two months prior?

I tried [Invoice Year Month]={'$Current_Month_YYYYMM)',-2}. but it doesn't work.

Please help me.

Ugur

2 Replies
JustinDallas
Specialist III
Specialist III

Hello Yogurt,

Just a few questions, is [Invoice Year Month] in the format of "YYYY MM" as in "2016 08"?  If so, you would have to convert it to a date:

Date#([Invoice Year Month], 'YYYY MMM')

Then take that date and subtract two months

AddMonths(Date#([Invoice Year Month], 'YYYY MMM'), -2 )


Then, convert that to your format


Date(AddMonths(Date#([Invoice Year Month], 'YYYY MM'), -2 ), 'YYYY MM')


So you should get something like this


COUNT({<[Invoice Year Month]={"$(=Date(AddMonths(Date#([Invoice Year Month], 'YYYY MMM'), -1 ), 'YYYY MM'))"}>} [Invoice Id])


I'm not sure about the set analysis syntax though.  Hope this helps.

ugurarslan
Creator
Creator
Author

Hi,

Unfortunately didn't work.

The result is 0.

Thanks

Ugur