Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Finding new records in Latest ID by compared with previous ID

Hi Everyone,

I need to find out the new records that were arrived in Latest Time ID by compared with previous Time ID. Below is my sample data set.

I want to set the "NoPrevious" flag in Qlikview By comparing with previous Time Id.

Can any one assist me to get it done.

Logic:

If(TimeID = Previous(TimeID) and MeterCode<> Previous Time ID MeterCode,1,0)

Regards,

Shakila D

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

I think this should work for you if I understand you right:

2017-12-12 00_39_22-Finding new records in Latest ID by compared wi... _ Qlik Community.png

You need to combine the two fields into one to be able to make use of the Exists() function to check if previously loaded values exists already in memory. The Previous() function will be of no help as it always refers to the source rows and thus can't combine any source fields at all.

View solution in original post

7 Replies
petter
Partner - Champion III
Partner - Champion III

I think this should work for you if I understand you right:

2017-12-12 00_39_22-Finding new records in Latest ID by compared wi... _ Qlik Community.png

You need to combine the two fields into one to be able to make use of the Exists() function to check if previously loaded values exists already in memory. The Previous() function will be of no help as it always refers to the source rows and thus can't combine any source fields at all.

luismadriz
Specialist
Specialist

Hi Shakila,

Maybe try something like this?

Temp:

LOAD

    Code,

    TimeID,

    "Timestamp",

    "No Previous"

FROM [lib://AttachedFiles/Data set.xlsx]

(ooxml, embedded labels, table is Sheet1);

DATA:

Load *,

     IF(Code=Previous(Code),'Old','New') as Flag,

     IF(Code=Previous(Code),0,1) as NewNoPrevious

Resident Temp

Order by Code,TimeID;

Drop Table Temp;

I hope it helps,

L

Anonymous
Not applicable
Author

Thanks for the reply Luis.

But What I need is I want to calculate the NoPrevious column in Excel. My dataset is only have TimeID,Code & Timestamp alone. I want to set the NoPrevious Flag based upon Above logic which i mentioned.

I just provide the sample Output  in Excel along with NoPrevious column.

TimeIDCodeTimestamp
69123456502-10-2017 00:00
69789632102-10-2017 00:00
70123456509-10-2017 00:00
70789632109-10-2017 00:00
70345678909-10-2017 00:00
71345678916-10-2017 00:00
71751234820-10-2017 00:00
727896321

20-10-2017 00:00

Anil_Babu_Samineni

Can you explain result as well with new column, If you aware?

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
luismadriz
Specialist
Specialist

Hi,

That will work based on that data. I'm not using NoPrevious in that logic


Regards,


Luis

Anonymous
Not applicable
Author

Thanks Petter, It works as I expected.

Anonymous
Not applicable
Author

Petter,

Can you please help me how the below highlighted command will works? Because the td-1 will take different date value, then how it getting matched with TC and set the flag as 1/0.

If(Exists(TC,(TD-1)&'_'&Code),0,1) As NoPrevious;