cancel
Showing results for 
Search instead for 
Did you mean: 

Creating column with previous month

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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:

Best regards

Patrik

Answers (1)

Answers (1)

lbreddemann
Active Contributor
0 Kudos

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