Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Qlik Sense- Count from previous month

Hey guys,

I want a KPI with the number of records from the previous month.

So I'm trying to do the following:

=count({$<Date_Year={'$(=year(vMaxData))'}, Date_Month={"=$(=addmonths(month(vMaxData),-1))"}>} Canal)

vMaxData is a variable I created as max date. And it is working because I use it in other calculations.

this way is not giving any error but the counting is not right.

Can you help me?

Best Regards,

Miguel Cunha

Labels (1)
21 Replies
Anonymous
Not applicable
Author

It worked now!

Thank you so much!

Best regards,

Miguel Cunha

YoussefBelloum
Champion
Champion

Month() function returns a months in an MMM format, but his Date_Month format is MM here..

sunny_talwar

I saw that, but not sure... may be it is dual with string and number value...

YoussefBelloum
Champion
Champion

you mean Month() is returning dual values ?

YoussefBelloum
Champion
Champion

EDITED

miguelcunha

just curious about the last one above, just test it and tell me please

no need to do this, I didn't saw the extra = on all the suggestions above...

sunny_talwar

I mean that Date_Month is a field created like this in the script

Month(Date) as Date_Month

Anonymous
Not applicable
Author

Didn't work mate. It gave me the same result as when I had Date_Month={"=$(=addmonths(month(vMaxData),-1))"}

YoussefBelloum
Champion
Champion

I see, i was focusing on the output described above (01 02 03..) indeed, Month() return dual values.. but don't know it depends on what it displays a month name or an integer as an output..

sunny_talwar

Month() will display text and Num(Month()) will display number..... unless the environmental variable has been changed to show number also....

YoussefBelloum
Champion
Champion

so here op's environnement variables is changed ? because when he put it on listbox, it displays 01 02, and when yo use your expression with Month(Addmo... it works..

so what's your thought here ?