Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Detect Change in value

I have a dataset with many rows that I need to clean. The data consists of PersonTripID as unique identifier for every person's every trip location. Person is identified as PersonID. For a given PersonID, I wish to detect change in location of the person.This helps me remove samelocations and obtain a unique trip for every person.

 

Initial dataset:

PersonLocationIDPersonIDLocationDateCount
10011San Diego1/1/20181
10021LA1/2/20181
10031LA1/3/20181
10041Las Vegas1/4/20181
10052NYC1/5/20181
10062Niagara Falls1/6/20181
10072Boston1/7/20181
10085Orlando1/8/20181
10095Miami1/9/20181
10105Miami1/10/20181
10115KeyWest1/11/20181
10125Miami1/12/20181
10135Orlando1/13/20181
10145Orlando1/14/20181
10153Houton1/15/20181
10163Austin1/16/20181
10173Houston1/17/20181


Final Dataset:

PersonLocationIDPersonIDLocationDateCountChange
10011San Diego1/1/201811
10021LA1/2/201811
10031LA1/3/201810
10041Las Vegas1/4/201811
10052NYC1/5/201811
10062Niagara Falls1/6/201811
10072Boston1/7/201811
10085Orlando1/8/201811
10095Miami1/9/201811
10105Miami1/10/201810
10115KeyWest1/11/201811
10125Miami1/12/201811
10135Orlando1/13/201811
10145Orlando1/14/201810
10153Houton1/15/201811
10163Austin1/16/201811
10173Houston1/17/201811


I was trying like this:

change=if(location<>earlier(location),1,0)

 

 

Thanks,

Milay

1 Reply