Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
ashis
Creator III
Creator III

Previous month value

Hello,

I have NumMonth field in my master calendar, and I am using the following code to generate NumMonth.

num(Month(TempDate)) As NumMonth

Now I want to get previous months count m based on my month selection. I am using this code.

=count({$< NumMonth={"=num(max(NumMonth))-1"}>} Reconciliation_ID)

This code is giving me current months count. if I hard code the value as

=count({$< NumMonth={5}>} Reconciliation_ID)  I get the result . however it is not working with the code I am using.

Please help

Thank you,

Ashis

1 Solution

Accepted Solutions
Brice-SACCUCCI
Employee
Employee

Hello,

please add this field to your model : Year(Date) * 12 + Month(Date) as [Month Counter].

And then your set analysis becomes [Mounth Counter] = {'$(=MAX([Month Counter] - 1))'}.

Il you use Num Month, you will have an issue in January. The solution I propose goes to December of the previous year.

Thanks,

Brice

View solution in original post

16 Replies
Anil_Babu_Samineni

You can use this?

=count({$< NumMonth={'$(=Max(NumMonth)-1)'}>} Reconciliation_ID)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ashis
Creator III
Creator III
Author

Thank your for your reply,

It is giving me 0 as value.

jmvilaplanap
Specialist
Specialist

Hi,

If you put the formula (=num(max(NumMonth))-1) in a label, what's the result? is 5?


Regards

ashis
Creator III
Creator III
Author

I am printing it in a text box

so if I put your code it is giving me 7 (numeric value ) if the month Aug(8) is selected.

Anonymous
Not applicable

Hi

Please try this

=count({$< NumMonth={'$1(=Max(NumMonth)-1)'}>} Reconciliation_ID)

Regards

Tahemas Momin

sunny_talwar

I would think this to work from Anil

=Count({$<NumMonth={'$(=Max(NumMonth)-1)'}>} Reconciliation_ID)

With a slight issue that what would you want to see when Jan is selected?

ashis
Creator III
Creator III
Author

Thanks for your reply . No it did not work.

Anonymous
Not applicable

To get the previous month of current selection

=num(max({$}MonthNum))-1

to get the previous Selection

=num(max({$1}MonthNum))-1

Regards

Tahemas Momin

Brice-SACCUCCI
Employee
Employee

Hello,

please add this field to your model : Year(Date) * 12 + Month(Date) as [Month Counter].

And then your set analysis becomes [Mounth Counter] = {'$(=MAX([Month Counter] - 1))'}.

Il you use Num Month, you will have an issue in January. The solution I propose goes to December of the previous year.

Thanks,

Brice