Skip to Content
avatar image
Former Member

Creating column with previous month

I have this model with year-month (attributes) in the rows and KPIs (measures) in the columns. A simple tabular display of the content thereby obviously shows the KPI-values / month (and other attributes).

What is missing - and which I cannot figure how to do - is how to create columns showing the KPI-values / previous month (i.e. month - 1). To clarify the result would thereby look like this:

                              Sales     Prev Sales

January 2014          100          160

February 2014         105          100

March 2014              110          105

...       

I figure it must actually be pretty easy using restricted and/or calculated columns, but just cannot figure out how to do it (maybe I ate too much for x-mas). I much appreciate hints.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 26, 2015 at 01:40 PM

    You can simple create two views with the actual and prev. month sales and union these values to get them next to each other. This is method described in following post:

    Implementation of WTD, MTD, YTD Period Reporting in HANA using Calculated Columns in Projection

    Best regards

    Patrik

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 26, 2015 at 01:27 PM

    Why don't you use window functions (e.h. LEAD/LAG) to access the prior/following row?

    For your scenario, you could also use a self-join.

    Shouldn't be too difficult for you to find a fitting solution.

    - Lars

    Add comment
    10|10000 characters needed characters exceeded