Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL case eqvuivalent in qlikview

I have an case statement(working) in sql server. I have to write the same in qlik view. So, I used if statement for that, but it says there is an error.

It does not give the exact error, is there a way to debug this ??

case when isnull(count(y), 0) > 0 then  sum(x)/count(y) else 0 end

For this the if statement i am using is

if ( isnull(count(y),0) > 0 , sum(x)/count(y) , 0)

4 Replies
nagaiank
Specialist III
Specialist III

Try the following expression instead:

If( IsNull(Count(y)) or Count(y)=0, 0, Sum(x)/Count(y))  as your-field-name

Not applicable
Author

Yeah looks like it works with both.

Can you please explain, what was wrong with my code(other than the isnull syntax), and how is your code different from mine.

Why does it not work for positive condition?

nagaiank
Specialist III
Specialist III

IsNull(expr) Qlikview function Returns -1 (true) if expr is NULL, otherwise 0 (false).

So it is never >0

Hope this answers your question.

Not applicable
Author

Yes sir, it does.

Thank you.