Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
shruthibk
Creator
Creator

How to compare the id for the current date and the previous month

Hi all,

I need to compare the id's in the script level only. i tried to use peek and previous function this will compare by row wise not with previous month.

sample data attached

Thanks,

Shruthi

1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi,

Flag_Table:

LOAD *,

    if( Previous(ID)=ID and AddMonths(previous(Date),1)=Date,1,0) as Flag_Test

   

Resident Date

order by ID, Date;

drop table Date; 

Where the date is the table you have, but you need to ensure that you read the data as data, with DATE#(Date,'MM/DD/YYYY') as Date.

Best regards,

Cosmina

View solution in original post

6 Replies
sunny_talwar

Why is this 0?

Capture.PNG

annafuksa1
Creator III
Creator III

you should to use above function in chart, previous in script

please look at example in my app

Anonymous
Not applicable

Hi,

Flag_Table:

LOAD *,

    if( Previous(ID)=ID and AddMonths(previous(Date),1)=Date,1,0) as Flag_Test

   

Resident Date

order by ID, Date;

drop table Date; 

Where the date is the table you have, but you need to ensure that you read the data as data, with DATE#(Date,'MM/DD/YYYY') as Date.

Best regards,

Cosmina

shruthibk
Creator
Creator
Author

ya it should be 1

sunny_talwar

Did you look at the cocosmina‌'s response? It should have worked for you.... Is it not working?

shruthibk
Creator
Creator
Author

Thank you