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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Simple Count Query

Hi all,

I started using Qlikview this morning and have been asked to complete a project already started by a collegue.

I have had no training on Qlikview so am guessing as i go.

There is a graph showing customer contact data and am i trying to change this to show where we dialled an answer machine.

The current code is

count({$<Contacts={1}>} Distinct Account_Key) 

Which I belive to be counting the number of times the Contacts column says 1?

However when I try to reproduce this for where my answermachine column doesnt equal 0 i get "No Data to display" yet I know there is some.

Below are 2 of the many attempts I have tried but cannot work out what i am doing wrong.

count({$<Answerphone/={0}>} Distinct Account_Key)

count({$<Answerphone<>{0}>} Distinct Account_Key)


Any help much appreciated.
Regards
Jonny. </body>
1 Solution

Accepted Solutions
Not applicable
Author

It's a common mistake. The equals sign after Contacts doesn't mean what you think it does, it's more of a Set descriptor than an actual formula equal sign.

You need:

count({$<Answerphone={'<> 0'}>} Distinct Account_Key)


View solution in original post

7 Replies
Not applicable
Author

It's a common mistake. The equals sign after Contacts doesn't mean what you think it does, it's more of a Set descriptor than an actual formula equal sign.

You need:

count({$<Answerphone={'<> 0'}>} Distinct Account_Key)


Not applicable
Author

count({$<Contacts={0}>} Distinct Account_Key) : Count of the distinct occurrences of Account_Key in the current record set where Contracts=10

For allexcept the above , we can use count({1-$<Contacts={0}>} Distinct Account_Key) where 1 refers to the total set of data.

Another eg. count({1-$<Contacts={0,1,2}>} Distinct Account_Key) : all except 01,1,2

--Arun

johnw
Champion III
Champion III

NMiller's set description should do the trick. To explain what is going on further, the dollar sign (which is optional) says to start with the current selections. Then his set description says to modify the current selections by ignoring whatever is currently selected for Answerphone, and instead pretending that all non-0 values have been selected. As for the rest, distinct is there in case you have duplicate Account_Keys. Normally each occurrence would be counted, but distinct says to only count each Account_Key once.

Not applicable
Author

Thanks for both suggestions.

Sadly I can get neither to work!

Not sure if its a problem with my data set or me...

The Answerphone field can currently only be 1.81 or 0 so telling it i want to count everything but 0 should be future proof!

I tried

count({1-$<Answerphone={0}>} Distinct Account_Key)
as per Arun's suggestion returns no data.

I also tried

count({$<Answerphone={'<> 0'}>} Distinct Account_Key)
as per NMillers suggestion which I am sure should have worked!



johnw
Champion III
Champion III

Oops! Sorry, didn't notice the single quotes instead of double quotes. Single quotes is a literal, so you're looking for the literal <> 0. Double quotes is a search string, which is what you need here. You need to search for everything <> 0. So probably this:

count({<Answerphone={"<> 0"}>} distinct Account_Key)

Not applicable
Author

Woo Hoo!

I pulled the data into a table so i could see how the Account_Key, Answerphone and Contacts columns actually looked.

It was there I noticed that Answerphone wasnt a 0 but was 0.00. So using a combination of your suggestions i got


count
({$<Answerphone={"<> 0.00"}>} Distinct Account_Key)


To work!... I think..

Not applicable
Author

I retract my below accusation that Qlikview was lying to me.. Infact it was user error.

I forgot the field names are case sensitive.

------------------

Now I think its lying to me.

My graph has 2 using same code as above. One has the Line style with Full Accumulation and the Other the bar chart style with no accumulation.

The bar chart was not showing so as a test I set it to full accumulation. Now an exact match to my line only a bar chart and not line.. This produced no difference in the visual outcome.

However its almost 4 hours past my shift end so im considering giving up on this for tonight.

Many thanks for your help thus far.