Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count Function

I'm attempting to build an expression using the count function that shows me the count for a dimension based on a date.  The current expression I have is as follows:

=Count({$<[POS Date]={'10/31/2014'}>}[Instrument Type])

Any idea why it does not work?

1 Solution

Accepted Solutions
ToniKautto
Employee
Employee

The set expression search string needs to be closed with a double-quote.


=Count({$<[POS Date]={"$(=Date#('10/31/2014','MM/DD/YYYY'))"}>}[Instrument Type])


However, there is no point in making a static calculation like =Date#('10/31/2014','MM/DD/YYYY') in the set expression. This will only result in a text looking like 10/31/2014, meaning that the calculation just makes the expression look more complex and wastes time for one calculation. Just write the date direct in the expression, and this is equal to the expression above.


=Count({$<[POS Date]={"10/31/2014"}>}[Instrument Type])

View solution in original post

14 Replies
jaimeaguilar
Partner - Specialist II
Partner - Specialist II

Hi,

it could be easier to help you, if you can upload a little sample of your data,

regards

Not applicable
Author

Essentially what I'm trying to do is

Select Count(Instrument Type)

from <table)

where POS Date = '10/31/2014'

group by Instrument Type

Does this make sense?

ziadm
Specialist
Specialist

Hi =count({$} [Instrument Type]) Your set Analysis seems to be ok in terms of syntax and should not have a syntax error Do you have a zero value return. if so this means the condition found no data and maybe you should remove the $ for having the current selection Try this =count({} [Instrument Type]) Thanks Ziad

ziadm
Specialist
Specialist

Sorry Try this count({} [Instrument Type])

ziadm
Specialist
Specialist

=count({<[POS Date] ={'10/31/2014'}>} [Instrument Type])

I am not sure why the editor removes the single qoute

but anyway try removing the $ sign of the current selection

ToniKautto
Employee
Employee

The outcome of an expression will always depend on the dimension(s) that you use. The dimension and expression will then depend on your data model, so with all the details it is hard to advise on how you can address the issue.

If you can provide a simple sample QVW file with a description of you expected result, it will be possible to determine why you get your current results and also advise on changes to get your expected result

maxgro
MVP
MVP

PFA

anbu1984
Master III
Master III

Is format of [POS Date] is 'MM/DD/YYYY' ?


If [POS Date] is date then try this

=Count({$<[POS Date]={"$(=Date#('10/31/2014','MM/DD/YYYY'))}>}[Instrument Type])

Not applicable
Author

Anbu,

I tried that syntax and am seeing a syntax error with the parens.  See screen grab below:

Count Syntax.png

From what I can see the Parenthesis line up.