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: 
Not applicable

Last 3 months data

Hi Experts,

i have 3 years of data with date field , but i need last  3 months of data  Excluding current month.

for EX:-  now April month is current month but i need "JAN,FEB,MARCH"

once if enter to "MAY" month  i need   "FEB,MARCH,APRIL" data.

9 Replies
tamilarasu
Champion
Champion

Do you want set expression.? If so, try

Sum({$<Date={">=$(=MonthStart(AddMonths(Today(),-3)))<$(=MonthEnd(AddMonths(Today(),-1)))"}>} Sales)

PrashantSangle

Hi,

create variable in script like

vLast3MonthStartDate=Monthstart(today(),-4);

vLastMonthEndDate=MonthEnd(Today(),-1);

while loading data use variable in where clause

like

Load *

from table

where Date>=$(vLast3MonthStartDate) and Date<=$(vLastMonthEndDate)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
HirisH_V7
Master
Master

Hi,

Use this expression in your Table,



Sum({<Year=, Month =, Date={"$(='>=' & MonthStart(Today(), -2) & '<=' & MonthEnd(Today()))"}>} Sales)


HTH,

Hirish

HirisH
“Aspire to Inspire before we Expire!”
Not applicable
Author

Hi

I will suggest dont use expression as its lower the performance.

I already face issue on same.

Go by dreamer4 way suggested.

Define variables and pass to scripts.

That will faster performance while you loading data.

This all when you have high amount of data.

Regards,

Lokesh

SatyaPaleti
Creator III
Creator III

You have to create a Variable

vPreviousMonth =Monthstart(today(),-4);

vCurrentMonth =MonthEnd(Today(),-1);

Use the same Variable where you Required

vishalmanu
Partner - Creator
Partner - Creator

This should work and probably a correct answer

vinod22kv
Creator
Creator

Hi,

The bellow exprection is working fine for me.

=count({<Date = {'>$(=Max((Addmonths(Date,-3)))) <$(=Max (Addmonths(Date)))'}>} CallID)

chetanpatel
Contributor III
Contributor III

if  you want to select you can used  below equation

='('& Date(monthname ( Today()),'MMM') & '|'& Date(monthname ( AddMonths(Today(),-1)),'MMM')& '|'& Date(monthname ( AddMonths(Today(),-2)),'MMM')& ')'