Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
bhaskar1986
Contributor
Contributor

matching previous day data

Hi,

Below is the matching with combination of id to id & previous date data where we have to display null values.

trying below syntax in script

if(peek(id)<>id and peek(num(date)) <> num(date) as flag.

can you please help and thank in advance

bhaskar1986_0-1747941766212.png

 

Labels (2)
4 Replies
RafaelBarrios
Partner - Specialist
Partner - Specialist

Hi @bhaskar1986 
not really sure what your are trying to achieve here.

but consider that peek will give you the previously loaded row in a table. So, my guess is that you need to sort your table by id and date and then use the peek or previous

something like this:

loaded_data:
load * inline [
id,date
101, 1/1/2025
102, 1/2/2025
103, 1/3/2025
104, 1/4/2025
105, 1/5/2025
106, 1/6/2025
107, 1/7/2025
108, 1/8/2025
109, 1/9/2025
110, 1/10/2025
111, 1/11/2025
112, 1/12/2025
113, 1/13/2025
101, 1/11/2025
102, 1/12/2025
103, 1/13/2025
104, 12/1/2024
105, 12/2/2024
106, 12/3/2024
107, 12/4/2024
108, 12/5/2024
109, 12/6/2024
110, 12/7/2024
];
 
load 
   *,
   if(peek(id)<>id and peek(num(date)) <> num(date),<do something>,<do something else>) as flag
RESIDENT loaded_data
ORDER BY id asc,date asc;     //so you read all dates by id and then move to next id
 
drop table loaded_data;
 
you could use preceding load to make simpler
 
take a look on peek and previous

https://community.qlik.com/t5/Design/Peek-vs-Previous-When-to-Use-Each/ba-p/1475913

 

Best,

help users find answers! Don't forget to mark a solution that worked for you & to smash the like button!

Qrishna
Master
Master

can you please be clear of what you trying to do here? are you comparing curent id to previous id and date with previous date, if they are not same display null?

bhaskar1986
Contributor
Contributor
Author

matching current date id with previous id date and last written by order by but some how values not getting null values.

Qrishna
Master
Master

try: if(id=previous(id) and date=previous(date), 1) as flag.