Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Taylorcc
Contributor III
Contributor III

Count if value falls within the quarter

Hello, 

I would like to count all patients who are admitted to a hospital within the quarter.

Something like -

If(Admission_Date>= 01/10/2019  AND <= 31/12/2019, Count Admission_Number)

Thank you 

Labels (2)
1 Solution

Accepted Solutions
Mauritz_SA
Partner - Specialist
Partner - Specialist

Hi @Taylorcc 

Assuming that your Admission_Date is also in the DD/MM/YYYY format, you should be able to use something like:

Count({<Admission_Date = {">= 01/10/2019  AND <= 31/12/2019"}>} Admission_Number)

Update: Count({<Admission_Date = {">= 01/10/2019  <= 31/12/2019"}>} Admission_Number)

Alternatively you can use:

Count(If(Admission_Date >= Date('01/10/2019') AND Admission_Date <= Date('1/12/2019'), Admission_Number))

If your Date is giving you problems you can just put your Admission_Date in a Date() as well.

Hope this helps.

Regards,

Mauritz

View solution in original post

4 Replies
Mauritz_SA
Partner - Specialist
Partner - Specialist

Hi @Taylorcc 

Assuming that your Admission_Date is also in the DD/MM/YYYY format, you should be able to use something like:

Count({<Admission_Date = {">= 01/10/2019  AND <= 31/12/2019"}>} Admission_Number)

Update: Count({<Admission_Date = {">= 01/10/2019  <= 31/12/2019"}>} Admission_Number)

Alternatively you can use:

Count(If(Admission_Date >= Date('01/10/2019') AND Admission_Date <= Date('1/12/2019'), Admission_Number))

If your Date is giving you problems you can just put your Admission_Date in a Date() as well.

Hope this helps.

Regards,

Mauritz

Taylorcc
Contributor III
Contributor III
Author

Thank you! The second suggestion worked 

Do you know how I could count unique admission numbers? I tried to use Distinct before and after Admission_Number but this didn't work

THanks again!

Tanalex
Creator II
Creator II

I think you need SET ANALYSIS, then the DISTINCT before Admission_Number.

Mauritz_SA
Partner - Specialist
Partner - Specialist

Hi @Taylorcc 

Sorry, for some reason I added an unnecessary AND in the set expression. I updated it.

OLD: Count({<Admission_Date = {">= 01/10/2019  AND <= 31/12/2019"}>} Admission_Number)

NEW: Count({<Admission_Date = {">= 01/10/2019  <= 31/12/2019"}>} Admission_Number)

If you want to only count the distinct Admission_Numbers then use:

Count(DISTINCT{<Admission_Date = {">= 01/10/2019  <= 31/12/2019"}>} Admission_Number)

Hope it helps.

Mauritz