Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
ashok25006323
New Contributor III

Dynamic Months

I want last two months of data in dimension

how to write calculation condition 

Tags (1)
5 Replies
Partner
Partner

Re: Dynamic Months

Hello,

you can try

if((yourmonthvariable = month(today()) or yourmonthvariable = month(today()) -1) , yourmonthvariable)

But you must have select the actual year in filter for that

thiago_pinho
New Contributor III

Re: Dynamic Months

Actually you have to add a Calculated Dimension, Try this:

aggr(only({<Date={">=date(monthstart(today(),-6))"}>} MonthYr),MonthYr)

ashok25006323
New Contributor III

Re: Dynamic Months

I have date column and I want last two months in calculated dimension

thiago_pinho
New Contributor III

Re: Dynamic Months

Qlik dont work well creating calculated dimensions in Chart, so, use it just in an specific case. The best way is to create it on Script,  for example:

LEFT JOIN (Calendar) LOAD

MonthYr,

MonthYr as Last6Mos

RESIDENT Calendar

WHERE Date >= monthstart(today(),-2);

Partner
Partner

Re: Dynamic Months

If you use Monthstart you must subtract the number of days so it is not -2 but something like -60.