Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

subtract last 120 days from the given date

Hi All,

I have Date dimensions and it has daily values for last 6 months.I have to plot line chart for only 120 days.How can i restrict the date for those 120 days??

Eg;Date starts with (1/31/2015 ,1/30/2015  and ends with 8/1/2015).But,I have to show the daily values of line chart till 10/1/2015.Instead,of hard coding to 120 days is there any way to restrict for last 4 months on daily values ??

6 Replies
Anonymous
Not applicable
Author

create a flag field for this as below in your script and use it in your front-end calculations,

Let vEnd = num(floor(today()));

Let vStart = num(addmonths(date(vEnd),-3));

Data:

Load

Dte,

if(num(Dte)>=$(vStart) and num(Dte)<=$(vEnd),1) as Flg_Lst120Days

;

LOAD * INLINE [

    Dte

    11/1/2014

    12/1/2014

    1/1/2015

    2/1/2015

    3/1/2015

    4/1/2015

    5/1/2015

];

petter
Partner - Champion III
Partner - Champion III

If you want to do it without changing your load script or data model you can do it directly in your

expression by including a Set Expression like this:

     Sum( {<Date={">=$(=Date((Max(Date)-119)))"}>} Sales )

Not applicable
Author

Hi there,

I have attached an example. I have used 7 days for simplicity and based on your date selections it will always show only the past 7 days. If nothing is selected then today till seven days back. Please look at the expression on how its done.

Thanks

petter
Partner - Champion III
Partner - Champion III

2015-04-10 #1.PNG

Not applicable
Author

Hi All,

Thanks for your quick response.

I have not seen your attachment.If possible,Can you attach and send it to me.

Regards,

Naga

Not applicable
Author

Thanks for your all quick responses.