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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Add previous month to selection

hi!!

i v got tu do a graphic and chart of sells by month

but i want to compare previous month to selected month always

i do this :

=sum({$<month={$(=AddMonths(month,-1))}>} sells)

but it doesnt work

obviously because for exemple then i selected sptember there s no month agust in selected records, there s only september records !

how can i do that ???

13 Replies
Not applicable
Author

Hi king-greg.

You can do that using variables... See the file

Reggards,

Bruno

Not applicable
Author

it doesnt work

i create a variable : vtest=Date(AddMonths(month, -1))

i put

=sum( {$<month= {$(vtest)}>} MCD_B )

an nothing appeared!!

MayilVahanan

Hi

Try like this

in variable,  Month(AddMonths(Max(Date),-1)) gives Aug,if max(Date) equal to today

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Addmonths works with by adding a number of months to a date.

Try =sum({$<month={$(=Only(month)-1))}>} sells)


talk is cheap, supply exceeds demand
Not applicable
Author

it doesn wotks

i dont know how to do that

get 2 selections at a time !

Not applicable
Author

King, what's your Qlikview Server Version?

Not applicable
Author

11

Not applicable
Author

Create a variable "VAR_PreviousMonth" whit this expression:

=Num(Month(AddMonths(YourDateFieldHere, -1)))

And, next, in your graph's expressions, try this

Sum({<YourMonthFieldHere={'$(VAR_PreviousMonth)'}>} YourValueFieldHere)

Good Luck!

Bruno Oliveira

MayilVahanan

HI

Try like this

For Current month

    =Sum({<DateFieldName={"=$(=Max(DateFieldName))"}>} Sales)

For Previous month:

     =Sum({<DateFieldName={"$(=Addmonths(Max(DateFieldName), -1))"}>}Sales)

If not satisfy your requirement, can you post a sample file

Hope this helps you.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.