Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
dseelam
Creator II
Creator II

Avg distinct if condition

Hello All,

I am trying to write an script for distinct avg if values are greater then zero its working fine with this statement 

avg(DISTINCT(IF(AA>0,AA))AS AA,

below statement is working fine but its including zero when its averaging,how to incorporate greater then zero condition to below statement?

avg(DISTINCT( If(((A * 1) * (B * 1))>0 and (C * 1) * (B * 1) >0, ((C * 1) * (B * 1)) - ((A * 1) * (B * 1)),0))) as COMPCOST

Thanks,

D

1 Solution

Accepted Solutions
sunny_talwar

May be if you remove , 0 from the end of the if statement

avg(DISTINCT( If(((A * 1) * (B * 1))>0 and (C * 1) * (B * 1) >0, ((C * 1) * (B * 1)) - ((A * 1) * (B * 1)),0))) as COMPCOST

View solution in original post

1 Reply
sunny_talwar

May be if you remove , 0 from the end of the if statement

avg(DISTINCT( If(((A * 1) * (B * 1))>0 and (C * 1) * (B * 1) >0, ((C * 1) * (B * 1)) - ((A * 1) * (B * 1)),0))) as COMPCOST