Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
shanemichelon
Partner - Creator II
Partner - Creator II

Previous year for Pivot Table with Year/Month dimension

Hi all.

I am running into an issue where I have a table with a yearmonth dimension (ie, 2014-Nov,2014-Dec etc).  I have a column that is simply Sum(Sales) for the month sales.  I need a second column showing the sales for the same month of the previous year.

I can't work out how to achieve this.  What I want to do is use set analysis to change the YearMonth dimension to be one year previous. Something like: Sum( {$ <YearMonth={'$(=(Left(YearMonth,4)-1)&'-'&Right(YearMonth,3))'} > } Sales)

I know that doesn't work because the dollar sign expansion is done across the whole table, but I can't work out how to achieve the desired result.

It is driving me nuts because it seems straight forward!

22 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi Shane,

This is what I am suggesting you from the beginning, check my first post for the same solution.

Regards,

Jagan.

shanemichelon
Partner - Creator II
Partner - Creator II
Author

Hello Jagan.  Yes I am aware that your solution is basically the same as what I did in the end.  However, it is not a solution but a work around.  In my case it will be sufficient, however, what if the client wanted to see the most recent four months, even if that was across year boundaries?  What if the desired result was like this:

YearMonthSalesSales Prev Year
Nov 201310090
Dec 2013110105
Jan 2014123132
Feb 2014654567

The 100 would be sales for Nov 2013, and the 90 would be for Nov 2012.

In this case, my (and Your) solution would not work.  For clarity, the user would need to see both month and year in the first column. Because the year can change from row to row, the dimension must be year and month.

I now believe this is not possible in Qlikview.

kinahan7
Contributor III
Contributor III

Is there any way to show the desired outcome in a pivot?  I would like to see the result from the row above in a pivot with the ability to bring in multiple dimensions - I thought ABOVE would do this, but not when including multiple dimensions in the pivot.  This can easily be achieved in DAX using PREVIOUSMONTH.

     

YearMonthSalesSales Prev MonthSales Prev Month % DifferenceSales Prev Year
Nov-131000-100.0%90
Dec-13110100-9.1%105
Jan-14123110-10.6%132
Feb-14654123-81.2%567