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: 
Not applicable

Comparing successive data

Hi!

I have a table with metered volumes pr day (date). I want to compare the values for subsequent days, and set a flag/comment if the values are the same. How do I do this in an expression in qlikview?

Ex:

Prod.date     Volume     Message

5/1/2014       105               OK

5/2/2014       107               OK

5/3/2014       107               Wrong

5/4/2014       114               OK

The logic is that I get a flag/message on 5/3/2014 as stated in example above.

BR, Frode

1 Solution

Accepted Solutions
eduardo_sommer
Partner - Specialist
Partner - Specialist

I removed the peek and created a straight table with the Date as a dimension and Volume as the expression. Then, I added a expression

    if (Volume=Above(Volume), 'Wrong', 'Ok')

and it worked.

See the new app attached

Eduardo

View solution in original post

7 Replies
julian_rodriguez
Partner - Specialist
Partner - Specialist

You can use the Peek function, on the load script.

Something like

Table_Example:

LOAD

     [Prod. Date],

     Volume,

     If(Peek('Volume') = Volume, 'Wrong', 'OK') As Message

FROM (Your source);

It works if the table is correctly sorted

Regards,

eduardo_sommer
Partner - Specialist
Partner - Specialist

Hi, Frode

Use this script (I changed the date format due to my region)

Table:

Load ProdDate,

    Volume,

    if(Volume=peek(Volume), 'Wrong', 'Ok') as Message;

Load * inline [

ProdDate,    Volume

1/5/2014,105

2/5/2014,107

3/5/2014,107

4/5/2014,114

];

See the attached qvw

Eduardo

Not applicable
Author

Hi!

Thank you for your quick responses. However, peek did not give me the wanted result. I want to check the record before (or after, dependant of sorting) in an already loaded table.

BR, Frode

eduardo_sommer
Partner - Specialist
Partner - Specialist

I removed the peek and created a straight table with the Date as a dimension and Volume as the expression. Then, I added a expression

    if (Volume=Above(Volume), 'Wrong', 'Ok')

and it worked.

See the new app attached

Eduardo

eduardo_sommer
Partner - Specialist
Partner - Specialist

If you need to check the record below, just change the Above to Below.

Eduardo

Not applicable
Author

That did the trick, thank you!!

eduardo_sommer
Partner - Specialist
Partner - Specialist

You're welcome, Frode