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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Previous Month Sum

I need to sum the dollar amount of the Previous Month based on the selected date(GLFileDate).

I set up a variable for PriorMonth
    (vPriorMonth)- =month(addmonths(max(GLFileDate),-1))

Set an expression below, but it returns $0.00

    =sum({$<GLFileDate=($(vPriorMonth))>}[Closing Balance USD])


I am able to get the Expression title to render the previous month, so I think the variables that I set up are functioning properly

   ='Previous Month: 
     $(vPriorMonth) $(vMaxDay), $(vPriorMonthYear)'

returns Previous Month: May 15, 2015 when 6/15/2015 is selected

Any suggestions?

Dan

1 Solution

Accepted Solutions
sunny_talwar

Or you can set your variable definition as this:

vPriorMonth =Date(AddMonths(Max(GLFileDate),-1), 'sameDateFormatasGLFileDate')

and then use

=Sum({$<GLFileDate={"$(vPriorMonth)"}>}[Closing Balance USD])

HTH

Best,

Sunny

View solution in original post

3 Replies
sunny_talwar

Hi, GLFileDate seems to be a date field and you are comparing date field to just a month. You probably would need to do something like this:

=Sum({$<GLFileDate={"=Month(GLFileDate) = $(vPriorMonth)'}>}[Closing Balance USD])

sunny_talwar

Or you can set your variable definition as this:

vPriorMonth =Date(AddMonths(Max(GLFileDate),-1), 'sameDateFormatasGLFileDate')

and then use

=Sum({$<GLFileDate={"$(vPriorMonth)"}>}[Closing Balance USD])

HTH

Best,

Sunny

Anonymous
Not applicable
Author

Thank you Sunny- this worked!

Or you can set your variable definition as this:

vPriorMonth =Date(AddMonths(Max(GLFileDate),-1), 'sameDateFormatasGLFileDate')

and then use

=Sum({$<GLFileDate={"$(vPriorMonth)"}>}[Closing Balance USD])