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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Getting previous month data in qlikview

attached is my qvw file. In management sheet there is a table called "Table of all questions (previos month) "

In this table i need to do same calculation but for the previous date.

One more thing, how can i place a title for the percentage column

7 Replies
Not applicable
Author

Hi,

To get the analysis for Current Month and Previous Month, you can define two variables in Variable Overview (Ctrl+Alt+V)

1. vCurrentMonth

Definition:  =Month(Today())

2. vPreviousMonth

Definition: =Month(AddMonths(Date(Today()),-1))

And modify your expressions to something like this:

=num(avg({<Month={$(vPreviousMonth)}>}MeanTotal)/100,'##%') for Previous Month

=num(avg({<Month={$(vCurrentMonth)}>}MeanTotal)/100,'##%') for Current Month

Please find attachment.

Hope it helps.

Regards,

-Khaled.

Not applicable
Author

Thnx for the reply, but this doesnt work if you select a date.

Any other ideas. I want the values to be shown even i select jan 2012, not without selecting any date

Not applicable
Author

Hi,

You can add a field to your calendar script as num(Month(Month)) as Month_Num and replace Month in the table expressions with Month_Num.

Modify the definitions for variables as follows:

1. vCurrentMonth

Definition: =num(Month)

2. vPreviousMonth

Definition: =if(num(Month)=1,12,num(Month)-1)

  • Use something like this expression for Current month

=num(avg({<Month_Num={$(vCurrentMonth)}>}MeanTotal)/100,'##%')

  • Use something like this expression for Previous Month

=num(avg({<Month_Num={$(vPreviousMonth)}>}MeanTotal)/100,'##%')

Hope it helps.

Regards,

Khaled.

Not applicable
Author

use : Date(addmonths(Max(MonthName), -1),'MMM YYYY')

as ur vPreviousMonth variable value

and modify ur expression for Previous Month to:

num(avg({<Month={"=$(vPreviousMonth)"}>}MeanTotal)/100,'##%')

Not applicable
Author

I used the following formula to get previous month

=MonthName(MonthName-1)  which give Nov 2012 when i select Dec 2012

but when i tried the formula 

num(avg({<MonthName={"=$(PrevMonth)"}>} MeanTotal)/100,'##%') it give me '-'

any other ideas???!!!!!

Not applicable
Author

did u change the value of variable as i mentioned & then use this expression ?

adarsh_a
Contributor III
Contributor III

Hi,

Its better to extract month and year separately and apply the expression.

 

num(Month(Date)) as Cal_Month,
Year(Date) as Cal_Year,

then apply the above expression, it works