Try this ways
LOAD *,Month(Date) as DMonth,NUM(Month(Date)) as NMonth; LOAD Date(Date#(Date,'DD/MM/YYYY'),'DD/MM/YYYY') as Date,Product, Amount; LOAD * INLINE [ Date, Product, Amount 01/01/2015, Bike, 3 01/01/2015, Accesories, 4 01/02/2015, Bike, 5 01/02/2015, Accesories, 6 01/03/2015, Accesories, 7 01/04/2015, Accesories, 8 01/04/2015, Bike, 9 ];
Check the attached qlik file for solution.
Prev.qvw 155.8 K
Thank you very much Anand,
Interestingly, the example seems to work fine for this pivoting table, but not for graphs (?). I added 2 charts with both measures, Sum(amount) and Above(Sum(amount)). The first chart is grouping by Product and NMonth; The second chart is grouping by NMonth and Product (the other way around). These are the results:
As you can see, the first chart for Month 3 and Bike Product is not showing "previous month sales". Instead Month 4 is showing 5 as "previous month sales".
The second chart does not show any previous month sales at all for Accesories.