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: 
Polido
Contributor II
Contributor II

How to get peek data with a condition?

Hello everyone!

I've tried to search if this was already solved on the forum but without luck.

I need to get the location from the last same 'vin' (vehicle identification number).

Right now I have the following: IF(vin = PEEK(vin),Peek(location)) AS peekLocation

But if vin <> peek(vin) then I don't know how to fetch the next most recent vin.

See the attached image to see the real data.

Thanks in advance!

1 Solution

Accepted Solutions
Thiago_Justen_

Hi there,

May be this:

 

YourDB_Table:

Load

         Your_DB_Fields

From Your_DB;

 

Your_Table:

Load

          Your_Fields,

          If ( vin = Previous(vin) , Previous(location), location)       As Last_Location

Resident YourDB_Table

                Order By

                                vin, YOUR_DATE_FIELD   

               Asc;

Drop Table YourDB_Table;

 

So, as @MarcoWedel said, you should be able to order resident table by vin and datetime field ascending (from older to newer values).

Regards,

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago

View solution in original post

3 Replies
MarcoWedel

you have to order by vin during load.
Please post some data as well as your expected result.

Thanks

Marco

Thiago_Justen_

Hi there,

May be this:

 

YourDB_Table:

Load

         Your_DB_Fields

From Your_DB;

 

Your_Table:

Load

          Your_Fields,

          If ( vin = Previous(vin) , Previous(location), location)       As Last_Location

Resident YourDB_Table

                Order By

                                vin, YOUR_DATE_FIELD   

               Asc;

Drop Table YourDB_Table;

 

So, as @MarcoWedel said, you should be able to order resident table by vin and datetime field ascending (from older to newer values).

Regards,

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
Polido
Contributor II
Contributor II
Author

Thank you very much for the help, it works!

 

Cheers 🙂