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: 
rossdickinson
Contributor
Contributor

Simple Column Count for > and = '0'

Hi,

I have a column called 'DEP_TIME' in my data set. It is measured in minutes.

If the DEP_TIME is on time, it is equal to 0.

Else, the DEP_TIME is late and has a value greater than 0.

I am looking to calculate the proportion of records on time (with '0') expressed as a percentage of all records.

So, something like this:

(Count of 'late' = '0') / ((Count of 'late' = '0') + (Count of 'late' > '0')) * 100

I am not familiar with Qlik custom functions, so I could please use some help!

Labels (1)
5 Replies
BrunPierre
Partner - Master II
Partner - Master II

Try this

COUNT({<DEP_TIME= {'0'}> } DEP_TIME) /

(COUNT({<DEP_TIME= {'0'}> } DEP_TIME) + COUNT({<DEP_TIME= {">0"}> } DEP_TIME) )  *  100

rossdickinson
Contributor
Contributor
Author

Hey,

I tried using a similar function and the results for

COUNT({<DEP_TIME= {'0'}> } DEP_TIME) alsways returns as '0'. Which is not the case, most of the values in the column are actually '0'. 

The format of '0' in the column is '0.00', not sure if that needs to changed?

BrunPierre
Partner - Master II
Partner - Master II

Then perhaps try the below or would you share the 'DEP_TIME' values

COUNT({<DEP_TIME= {'0.00'}> } DEP_TIME)

BrunPierre
Partner - Master II
Partner - Master II

@rossdickinson Is your question answered?

vinieme12
Champion III
Champion III

You need to count on a field that identifies each row uniquely 

example

=count( {<DEP_TIME={"0"}>}rowid) / count( {<DEP_TIME={">=0"}>}rowid)

or just

=count( {<DEP_TIME={"0"}>}rowid) / count(rowid)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.