Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get Previous Month

Hi Guyys,  i want to Find Out Previous Month Method. Suppose I have a One Year 2015 and 2014.. In that I want to

Compare the sum of sales month wise.. Like If I select 2015 as a Year and dec as a Month. so i get the Sum of sales

for Dec and Nov . as well if i select Year 2015 and Month Jan i get the sum of sales for Jan and Dec2014..

Kindly Help me ..

14 Replies
Not applicable
Author

Try this expression if you have date field in your data model

Month=Month(Addmonths(MakeDate(Year(max(Date)),Month(max(Date)),Day(max(Date))),-1))

in set expression while calculating Amount

timanshu
Creator III
Creator III

Hi,

Change expression to :

=if(Month= 'Jan',sum({<Month = {'Dec'}, Year ={'$(=Max(Year)-1)'}>} Price_Pcs_Incl_Discount),sum({<Month = {'$(=vPreviousMonth)'},Year ={'$(=Max(Year))'}>}>}Price_Pcs_Incl_Discount)).


If still doesn't work, then kindly attach qvw .

timanshu
Creator III
Creator III

Hi,

It will not change year if max month is jan.

Not applicable
Author

=month(monthstart(today())-1)

Not applicable
Author

Use following Expression

You need to create Period field  Period= Year&Month in script

then use in set expression Year=,Month=,Period = {$(=vPeriod)}

Where vPeriod is variable

vPeriod =Floor(max( if(mod(Period, 100) = 1, Period - 89, Period - 1)))

Regards,

Veeki

Plz Check App also