Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
BlakeGri2093
Contributor III
Contributor III

LMTD,LQTD,LYTD For All years

Hi guys

I have the question how to create flag for LMTD,LQTD,LYTD for all years in data. I tried this script below but it work for only MTD, QTD, YTD. 

MTD script: 

if(month(tempdate) = month(today(1)) and daynumberofyear(tempdate) <= daynumberofyear(today(1)),1,0) as MTDflag

 

Could you guys help me with that ?, thank in advanced

Labels (1)
1 Solution

Accepted Solutions
BlakeGri2093
Contributor III
Contributor III
Author

Based on your formula i figure out how to calculate LMTD and so on. Tks a lot

The right script is:

if(AddMonths(month(tempdate),0) = month(AddMonths(today(1),-1)) and daynumberofyear(tempdate) <= daynumberofyear(AddMonths(today(1),-1)),1,0) as MTD_LY_flag

 

View solution in original post

2 Replies
Anil_Babu_Samineni

Since you already got the flag for current year, May be use below condition for last year?

if(AddMonths(month(tempdate),-1) = month(AddMonths(today(1),-1)) and daynumberofyear(tempdate) <= daynumberofyear(AddMonths(today(1),-1),1,0) as MTD_LY_flag

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
BlakeGri2093
Contributor III
Contributor III
Author

Based on your formula i figure out how to calculate LMTD and so on. Tks a lot

The right script is:

if(AddMonths(month(tempdate),0) = month(AddMonths(today(1),-1)) and daynumberofyear(tempdate) <= daynumberofyear(AddMonths(today(1),-1)),1,0) as MTD_LY_flag