Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to make a "Count" on the previous month

Hi,

I'm new on this forum and i need your help:

Actually i'm calculating a Count(Id) for the current Month

But i want to display the result of a Count(Id) for the previous Month.

I tried this but it dosen't work :

Count(if(Month=AddMonths(Month,-1), _Id_Repair))

I tried this too:

Count(if(Month=$(=Only(Month)-1), _Id_Repair))

Any advices?

I want to add that i made a join between the date contained in Repair and a Calendar

Thanks in advance

4 Replies
matt_crowther
Luminary Alumni

Give this a try:

=count(if(Month=month(addmonths(today()),-1),_Id_Repair))

'Month' is the month from tyour data and 'month' is the month function from Qlikview.

That method works for me in similar situations and should give you the count for Feb 2011.

Hope that helps,

Matt - Visual Analytics Ltd

brenner_martina
Partner - Specialist II

Hi,

be careful, the function Month gives you in QV always a dual field: Text and Number (Jan,1; Feb,2;...) Thats why it is best you enter in your calender a Num(Month(datefield)) As NumMonth. Than you can use set analysis for your selection.

Count({<NumMonth={$(=(Only(NumMonth)-1))}>} Field)

Look at attached example

Not applicable
Author

I was thinking the problem was because of the number of month yeah.

Thank you for this answer!

But i tried your method and it doesn't work, i don't understand why..

I give you a part of my data model maybe it's because of my join :

Uploaded with ImageShack.us



Not applicable
Author

Hi,

Finally i find the solution!

I test on NumMonth like you said but with the name of the Month too :

{<NumMonth={$(=Only(NumMonth)-1)},Month=>}

And it works!

Thanks a lot for you help both of you.

Regards