Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Current Years Current Month Vs Last Year Same Month Data

Hi All,

Need to display data in Guage chart

Current Years Current Month Vs Last Year Same Month Data.

Example

2012 Jan Data Vs 2011 Jan Data .

How to acheive this pls suggest me an idea.

Thks in advance

10 Replies
Not applicable
Author

Current Year and Current Month Exp:

sum({$<Year={$(=Max(Year))},Month={ "<=$(max({<Year={$(=Max(Year))}>} Month))>$(Max({<Year={$(=Max(Year))}>}Month)-1)"}>}

Last Year and Current Month Exp:

sum({$<Year={$(=Max(Year-1))},Month={"<=$(Max({<Year={$(=Max(Year))}>}Month))>$(Max({<Year={$(Max(Year))}>}Month)-1)"}>}

Regards,

Venkat Reddy

Not applicable
Author

hi,

just use this expression and take month as dimension:

For Current year: =Sum({$<Year={$(=Max(Year))}>}Sales)

For last Year:-=  =Sum({$<Year={$(=Max(Year)-1)}>}Sales)

Refer to the atttached file:

Regards :

Arun Goel

Not applicable
Author

hi,

Last one is for bar chart,

for gauge chart use:

For current year-month=Sum({$<Year={$(=Max(Year))}, Mon={$(=Month(Today()))}>}Sales)

For last Year's same month=Sum({$<Year={$(=Max(Year)-1)}, Mon={$(=Month(Today()))}>}Sales)

Refer to attached file:

Enjoy!!!!!

Regards

Arun Goel

Anonymous
Not applicable
Author

hi Venkat,

Thanks for the suggestion

Current years Current month script works fine

Sum({$<Year={$(=Max(Year))}, Mon={$(=Month(Today()))}>}Sales)

but last year same month not working.

Sum({$<Year={$(=Max(Year-1))}, Mon={$(=Month(Today()))}>}Sales)... its returing consolidated of all the values for last year.

I need last years same month data ...

Example :   2012 Jan Data Vs 2011 Jan data

Thanks for the reply....

Not applicable
Author

try moving the closing bracket that's after Year-1 two positions to the left:

Sum({$<Year={$(=Max(Year)-1)}, Mon={$(=Month(Today()))}>}Sales)

You want the max(year) minus one, which is the previous year

Anonymous
Not applicable
Author

Hi

     Hope the attached file will be helpful for you

Regards

Ashok

Anonymous
Not applicable
Author

Hi All,

Thanks for the reply...

I think i cannnot use today function , bcoz the latest data in our file is 2012 jan data..

so i need to compare 2012 Jan data and 2011 Jan data...

@Ashok , ur attached file gives an idea but i cannot use today function

SunilChauhan
Champion II
Champion II

for current year

=Sum({$<Year={$(=Max(Year))},Month={$(=max(fis_period_id))}>} [total_sales])

for Previous Year

=Sum({$<Year={$(=Max(Year)-1)},Month={$(=max(fis_period_id))}>} [total_sales])

hope this helps

Sunil Chauhan
Anonymous
Not applicable
Author

Hi

     Then you can create a variable and set the date (jan 2012) like

     variable name = makedate(max(Year(Yourdatefield)),Max(Month(Yourdatefield)))

     Then apply this variable instead of the today() in that attached expression.

Regards

Ashok