Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
psk180590
Creator III
Creator III

Total of last 12 Months

Hello All,

I have the below dimension to get the sales of last 12 months in my Chart. But, this doesn't work somehow(Always gives 0). Can you please point out the error here.

sum(TOTAL<Artikel_Name> aggr(sum({<Month >= AddMonths(Today(), -12) >} Sales),Artikel_Name))

Thanks

Sai.

4 Replies
niclaz79
Partner - Creator III
Partner - Creator III

Your set-expression should be:


Month =  {"<= $(=Month(Today())) > $(=Month(AddMonths(Today(), -12)))"}


Provided that your Month-column is in the same format as Month(Today()) gives back.

psk180590
Creator III
Creator III
Author

Hi Niclas,

if(column(1)>0,

sum(TOTAL<Artikel_Name> aggr(sum({<MonatNum = {"<= $(=Month(Today())) > $(=Month(AddMonths(Today(), -12)))"} Sales),Artikel_Name))

)

You, mean something like this? But, this still gives me 0.

niclaz79
Partner - Creator III
Partner - Creator III

It’s hard to know what goes wrong without seeing your data. Can you upload the Qvw so I can take a look?

Från: Pakalapati Sai Kumar <qcwebmaster@qlikview.com>

Skickat: den 30 juli 2018 10:44

Till: Niclas Anderström <niclas.anderstrom@mindcamp.se>

Ämne: Re: - Total of last 12 Months

sunny_talwar

You want last 12 months? so why are you looking at just the month field.... do you have a monthyear field in your data? if you do... it might make sense to use that to get last 12 months...

Sum({<MonthYear = {"$(='>' & Date(MonthStart(Today(), -12), 'MMM-YYYY') & '<=' & Date(MonthStart(Today()), 'MMM-YYYY'))"}>} TOTAL<Artikel_Name> Aggr(Sum({<MonthYear = {"$(='>' & Date(MonthStart(Today(), -12), 'MMM-YYYY') & '<=' & Date(MonthStart(Today()), 'MMM-YYYY'))"}>} Sales), Artikel_Name))

Where MonthYear field is created like this in the script

Date(MonthStart(TempDate), 'MMM-YYYY') as MonthYear