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

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

Calculate Previous Months Data using a variable

Hi,

I'm really struggling with this issue.

I have some data that displays some data based on month selected. I would also like to get the data to display the previous months data. In my example I have 2 tables, one has it working if I hard code the month, the other is not working, when I try an use the variable.

I would really appreciate any help you offer with this.

Cheers

Simon

1 Solution

Accepted Solutions
udit_kumar_sana
Creator II
Creator II

Hi ,

Here is the attached file for your issue.

Regards,

Udit

View solution in original post

7 Replies
Anonymous
Not applicable
Author

do not hard code any thing make it flexible and dynamic

please see below expression for current month and previos month

current month :

=sum({<year={$(=max(year))}>},month={$(=max(month))}>}amount)

previos month :

=sum({<year={$(=max(year))}>},month={$(=max(month)-1)}>}amount)

Regards

Anant

Not applicable
Author

Hi,

Thanks for replying so  quickly.

We know not to hard code anything, which is what we are trying to avoid.

All I want to know is why it will work when we hard code the text, but when we use a variable which contains the same value, it does not?

Cheers

Simon

udit_kumar_sana
Creator II
Creator II

Hi ,

Here is the attached file for your issue.

Regards,

Udit

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

check the attached file

Not applicable
Author

Hi,

Thanks for this, I can stop pulling my hair out now!!

Much appreciated.

Cheers

Not applicable
Author

Hi,

Thanks for this, I can stop pulling my hair out now!!

Much appreciated.

Cheers

Not applicable
Author

Hi,

THank you to everyone thathelped me with this originally. Its been working a treat.

However I decided to create my dates a different way based on the data instead of a fixed table, which all works fine, but it has broken the way I get the previous data.

I've tried all sorts but cant get it to work.

I would really appreciate it if someone could help get it working again, and also explain to me why it works, so I have a better understanding if I brake it again.

Cheers