Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Last 13 months data

Hi Guys,

I have data of 20 period as 2013P01 format.

I have only one field yearperiod,,based on this how could i apply last 10 months data. whatever data come i always want to keep last 10 mnths data in my report. Could you please help me

7 Replies
Anonymous
Not applicable
Author

Hi Kalyani,

You can use below script in where clause to achieve that. Here, I am converting yearperiod field which has "2013P01" format to "1/1/2013" date format. 

Where Date(Date#(yearperiod, 'YYYYPMM'))>AddMonths(Today(), -10);

Hope it helps you

Satya

Not applicable
Author

Hi Satyadev..thanks a lot for your response.

But I have tried with the above expression but it is not working.

While loading yearperiod I an restricting with thus expression,but not working for me,

MarcoARaymundo
Creator III
Creator III

Hi!

Try this. In your expression put:

Sum({<YEARPERIOD={">=$(=AddMonths(Today(), -10))<=$(=Date(Today(),'YYYYMM'))"}>} FIELD)

Anonymous
Not applicable
Author

Hi Kalyani,

Are you getting any error? Could you share a sample app to understand more on this.

The above script first converting yearperiod which is in "2013P01" format to date format and extracting last 10 months data by comparing with addmonths(today(), -10). 

jagan
Luminary Alumni
Luminary Alumni

Hi,

LOAD

*,

MakeDate(Left(MonthFieldName, 4), Right(MonthFieldName, 2)) AS DateFieldName

FROM DataSource;


Now use this expression


=sum({<MonthFieldName=, YearFieldName=, DateFieldName={'>=$(=MonthStart(Max(DateFieldName), -10))<=$(=Date(Max(DateFieldName)))'}>} MeasureName)


or


=sum({<MonthFieldName=, YearFieldName=, DateFieldName={'>=$(=MonthStart(Max(DateFieldName), -9))<=$(=Date(Max(DateFieldName)))'}>} MeasureName)



Regards,

Jagan.

Not applicable
Author

hi guys thanx  a lot,it works

jagan
Luminary Alumni
Luminary Alumni

Hi Kalyani,

Please close this thread by giving Correct and Useful Answers to the posts which are helpful to you, so that it would be helpful for others.

Regards,

Jagan.