5 Replies Latest reply: Mar 8, 2018 11:08 AM by Pete Bolin

# How to count values between two dates (variables)

I've seen a few questions regarding this, which have been very helpful, but I still can find the answer to this.

I created two variables, one which calculate three days before the first day of a month and the second which calculates three days before the end of a month. Here they are:

vEndDateminus3=  date(monthend(APH_DATE)-3, 'M/D/YY')

vStartDateminus3= date(MonthStart(APH_DATE)-3, 'M/D/YY')

I have values called COI which I'd like to count how many occured between vStartDateminus3 and vEndDateminus3. This is what I have:

Count({<{'\$(=vStartDateminus3)'} = {'>=\$(=vEndDateminus3)'}>}[COI])

Not working! Any help would be appreciated!

• ###### Re: How to count values between two dates (variables)

try like this:

Count({\$<APH_DATE = {'>=\$(=vStartDateminus3) <=\$(=vEndDateminus3)'}>}[COI])

• ###### Re: How to count values between two dates (variables)

I'd suggest you:

Count({\$<APH_DATE = {">=\$(=\$(vStartDateminus3))<=\$(=\$(vEndDateminus3))"}>}[COI])

Double quotes are needed here.

• ###### Re: How to count values between two dates (variables)

Or may be -

Count({\$<APH_DATE = {">=\$(vStartDateminus3)<=\$(vEndDateminus3)"}>}[COI])

• ###### Re: How to count values between two dates (variables)

If the variables are defined as dates, you will need

Count({<APH_DATE = {">='\$(vStartDateminus3)' <='\$(vEndDateminus3)'"}>} COI)

• ###### Re: How to count values between two dates (variables)

Thanks everyone, very helpful! I ran this to check if I could 1) use this logic as measure called #aphs 2) make sure there are COI's within the start date-3...end date-3 range and 3) audit my minus3 variable.

#aphs = Count({<APH_DATE = {">='\$(vStartDateminus3)' <='\$(vEndDateminus3)'"}>} COI)

I'm very new to Qlik so sorry for the delay response and perhaps my filters are the issue. Thanks agian.