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: 
Not applicable

Count Function - only look at selection?

Hi,

From what I understand, =count({$<Leg={"Allocation"}>}[Trade ID])  should only be looking at the current selection, right? However, adding a Leg listbox in and filtering out all Allocation trades, it still shows 1.

I honestly can't share any data and I would only prepare an extract if really required - have ever seen this sort of problem though and are there some easy things to look at first maybe?

Thanks!

8 Replies
MK_QSL
MVP
MVP

=count({$<Leg={"Allocation"}>}DISTINCT [Trade ID]) 


What is your requirement? Not clear from your question.

hic
Former Employee
Former Employee

It does not look at the current selection. It takes the current selection, and modifies this according to your set expression. So, in your case, it doesn't matter what the selection in "Leg" is - it will always look at 'Allocation' only.

HIC

Not applicable
Author

Oh that's interesting! Thank you Henric Cronström, that changes a lot. How would I count the number of Leg=Allocation in the current selection?

tresesco
MVP
MVP

May be this?

=count({$<Leg={"Allocation"}>} Leg)

Not applicable
Author

That would still change the selection to Allocation, just counting on a different field right? So wouldn't solve it.

tresesco
MVP
MVP

Sorry, did not get your requirement properly. Could you elaborate a bit more?

Not applicable
Author

Count how many Leg=Allocation there are in the current selection. If allocation isn't selected from a different listbox, this should obviously be 0.

tresesco
MVP
MVP

=count({$<Leg={"=Leg='Allocation' "}>} Leg)

Or,

Count(If(Leg='Allocation', Leg))