Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
wanyunyang
Creator II
Creator II

count number of months

I have a date 11/2017 and a year filter. I'm trying to count the number of months. I

f I select year 2016 in the filter, it returns 0. If select 2017, returns 2 (11/2017, 12/2017). If select 2018, it will count till today, so returns 7 (11/2017, 12/2017, 01/2018, 02/2018, 03/2018/, 04/2018, 05/2018).

What should the function be for this?

Thanks in advance!

8 Replies
sunny_talwar

I have a date 11/2017 and a year filter.

Where is this date coming from?

wanyunyang
Creator II
Creator II
Author

year(date) is the year filter.

sunny_talwar

My question was where is this date coming from

wanyunyang
Creator II
Creator II
Author

Just Nov 2017

sunny_talwar

Not sure I understand, is there a sample your can share to explain your problem?

jerem1234
Specialist II
Specialist II

You can try either of these:

=count({$*<Date = {'>=$(=date(date#('11/2017', 'MM/YYYY')))'}>}Date)

=count(if(Date>=date#('11/2017', 'MM/YYYY'), Date))

This assumes that your Date field is in the format of 'MM/YYYY' hence it is just a standard count. You might have to use distinct in your expression as well depending on your data:

=count(DISTINCT{$*<Date = {'>=$(=date(date#('11/2017', 'MM/YYYY')))'}>}Date)

I also assumed your date 11/2017 is hard-coded or a certain date you have in mind. If its dynamic, you might have to use variables and tweak the code.

Hope this helps!

rafatashiro
Contributor III
Contributor III

Hi,

U can try this:

Count( {<Date= {">=Date#(11/2017,'MM/YYYY')<=Max(Month))"}>} Month )

Anil_Babu_Samineni

May be this?

Count( {<Year_Month= {">=$(=MinString(Year_Month))<=$(=MaxString(Year_Month)))"}>} Month)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)