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

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Average when value <> 0

I want a function to calculate average, but only when the value is <> 0.

Numbers: 100, 0, 200

AVG(Number): 100 (100+0+200 / 3)
I want 100+200 / 2 = 150

Thank in advance!

1 Solution

Accepted Solutions
stephencredmond
Partner - Specialist II
Partner - Specialist II

Hi,

Use a set to exclude zero:

=Avg({< F1 -= {0}>} F1)

Stephen

View solution in original post

4 Replies
stephencredmond
Partner - Specialist II
Partner - Specialist II

Hi,

Use a set to exclude zero:

=Avg({< F1 -= {0}>} F1)

Stephen

Not applicable
Author

Use Set Analysis:

Avg({<Numbers = {'>0'}>} Numbers)


EDIT: Didn't see Stephen's reply when I posted. His will work for you.

Not applicable
Author

sum(Number) / count( if(Number>0,Number))

JJ

stephencredmond
Partner - Specialist II
Partner - Specialist II

Thanks for the question, it inspired a blog post:

http://qliktips.blogspot.com/2010/01/more-on-sets-or.html

BTW to the other guys - your ">0" set implies that all the numbers will be positive.

Stephen