Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Highlighted
Not applicable

Peek function help

Here is my script and qvw file attached

TEMP:

LOAD * INLINE [

    Vendor, Date, Value

    1, 1/1/2016, 100

    1, 2/1/2016, 200

    2, 3/1/2016, 300

    2, 4/1/2016, 400

    3, 5/1/2016, 200

    4, 6/1/2016, 100

    4, 7/1/2016, 100

    5, 8/1/2016, 90

];

Data:

LOAD*,Peek('Value') as NextMonthValue

Resident TEMP

Order By Vendor, Date desc;

Drop Table TEMP;

                                                                  

Here is the result

Vendor  Date          Value     NextMonthValue

1          1/1/2016     100         200

1          2/1/2016     200         -

2          3/1/2016     300         400

2          4/1/2016     400         100

3          5/1/2016     200         300

4          6/1/2016     100         500

4          7/1/2016     500         200

5          8/1/2016     90           100


Here is what I want.  Grab next months value.  If Vendor has no value for next month, null.   Need to do this in the script, not expression

Vendor  Date          Value     NextMonthValue

1          1/1/2016     100         200

1          2/1/2016     200         -

2          3/1/2016     300         400

2          4/1/2016     400         -

3          5/1/2016     200         -

4          6/1/2016     100         100

4          7/1/2016     500         -

5          8/1/2016     90           -

1 Solution

Accepted Solutions

Re: Peek function help

Try this:

TEMP:

LOAD * INLINE [

    Vendor, Date, Value

    1, 1/1/2016, 100

    1, 2/1/2016, 200

    2, 3/1/2016, 300

    2, 4/1/2016, 400

    3, 5/1/2016, 200

    4, 6/1/2016, 100

    4, 7/1/2016, 500

    5, 8/1/2016, 90

];

Data:

LOAD *,

  If(Vendor = Previous(Vendor), Peek('Value')) as NextMonthValue

Resident TEMP

Order By Vendor, Date desc;

Drop Table TEMP;


Capture.PNG

5 Replies

Re: Peek function help

Try this:

TEMP:

LOAD * INLINE [

    Vendor, Date, Value

    1, 1/1/2016, 100

    1, 2/1/2016, 200

    2, 3/1/2016, 300

    2, 4/1/2016, 400

    3, 5/1/2016, 200

    4, 6/1/2016, 100

    4, 7/1/2016, 500

    5, 8/1/2016, 90

];

Data:

LOAD *,

  If(Vendor = Previous(Vendor), Peek('Value')) as NextMonthValue

Resident TEMP

Order By Vendor, Date desc;

Drop Table TEMP;


Capture.PNG

Not applicable

Re: Peek function help

Thank you Sunny!

oknotsen
Honored Contributor III

Re: Peek function help

If your question is now answered, please flag the Correct Answer (via the big "Correct Answer" button near every post).

If not, please make clear what part of this topic you still need help with .

May you live in interesting times!
Not applicable

Re: Peek function help

Onno,

I do not see a "Correct Answer" button near any posts.  I've seen this button before in the past but do not see it anywhere now.  There's an "Actions" drop down menu with "Marked as Helpful".  That's the only action available located on every post.

Sunny did answer my question.

Re: Peek function help