
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- « Previous Replies
- Next Replies »
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, may be you need Month on top of AddMonths
=Count({$<Date_Year = {'$(=Year(vMaxData))'}, Date_Month = {"$(=Month(AddMonths(vMaxData, -1)))"}>} Canal)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
supposing that your Date_Month field is a MONTH FIELD (example 1, 2, 3...12), try this:
=count({$<Date_Year={'$(=year(vMaxData))'}, Date_Month={"=$(=num(Month(addmonths(vMaxData,-1))))"}>} Canal)
if your Date_Month field is a date field, try this:
=count({$<Date_Year={'$(=year(vMaxData))'}, Date_Month={"=$(=addmonths(vMaxData,-1))"}>} Canal)
if none of these expressions works, try to share with us your Date_Month format

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi youssefbelloum
None of them worked.
My Date_Month is Month(DataImport) As Date_Month.
The DataImport format is DD-MM-YYYY.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
what do you have exactly on your vMaxData variable ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
=Max(Date_Date)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok, so the problem on your original expression is this:
addmonths() function takes a date to roll back but you give it a Month
Date_Month field is in this format: 01 02 ...12 or this format 1 2 3 12 ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it's in the 01, 02 format

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have an extra = sign... can you see if it works after you remove it?
=count({$<Date_Year={'$(=year(vMaxData))'}, Date_Month={"=$(=addmonths(month(vMaxData),-1))"}>} Canal)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, may be you need Month on top of AddMonths
=Count({$<Date_Year = {'$(=Year(vMaxData))'}, Date_Month = {"$(=Month(AddMonths(vMaxData, -1)))"}>} Canal)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try this:
=count({$<Date_Year={'$(=year(vMaxData))'}, Date_Month={"=$(=num(Month(addmonths(vMaxData,-1)),00))"}>} Canal)

- « Previous Replies
- Next Replies »