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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Add Value from Last Year in Table

Hello,

I have the following table:

    - Period: YYYYMM

PeriodValue
20150110
20150215
2015035
20150420
20150525
20150630
201507100
201508150
201509135
201510500
201511200
201512235
2016015
20160215
20160320
20160450
20160545
20160695
20160770
201608750
201609200
201610250
201611380
201612355

What I need is to create a table like this:

PeriodValuePrevious_Value
201601510
2016021515
201603205
2016045020
2016054525
2016069530
20160770100
201608750150
201609200135
201610250500
201611380200
201612355235

This table contains last 12 months with the corresponding VALUE and the PREVIOUS_VALUE from last year.

Do you know how could I do this, directly on my Straight Table as an expression?

Because I've tried doing something like: =Above(Sum({<Period>} Value), 12) * Avg(1)

And it shows me the following which is ok if I don't touch anything:

1.png

But when I sort the table by Period, I don't see it correctly:

2.png

Or if I make a selection for a Year, I can't see the last year value (or if I select some periods):

3.png

I'd need to create this expression on QlikView (and also Qlik Sense), without breaking the object.

Is there any solution for this? I've been searching since a long time and didn't find it so far.

Thank you!

2 Replies
Anil_Babu_Samineni

Don't worry about that?

Use this expression for last year

=Above(Sum({1<Period>} Value), 12) * Avg(1)



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
Digvijay_Singh

I don't have license so cannot open your QVW, if you write your expression like below, I think it will do sorting properly -

Exp 1 - Aggr(Sum({1<PeriodSeq={">=$(=Max({1}PeriodSeq)-11)"}>}Value),PeriodSeq)

Exp 2 - Aggr(Above(Sum({1} Value), 12) ,PeriodSeq)

I have added new field PeriodSeq so that comparison can be performed easily, added in the script as -

AutoNumber(Period) as PeriodSeq

Check below the list in descending order showing properly, also it won't be affected by any select as we have used {1} in aggregation function to disregard the selections.

Capture.PNG