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: 
Not applicable

Using if-clause to calculate either sum or avg

Hi,

I'm trying to calculate sum or average of values on the same column/expression using if-clause. For some reason this gives me wrong results.

if(wildmatch(UnitDesc, '*xyz*') = 0,

sum(),

avg()

)

UnitDesc is used as a dimension, so each row should only contain sum or avg calculations, never both on the same row. What is the correct way of doing this in Qlikview?

1 Solution

Accepted Solutions
Not applicable
Author

Nevermind, I had the wrong field-name in my expression. Need to be more careful when having similiar field names in my document.

View solution in original post

5 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Sum or Avg of which field?

The syntax is Sum(Field) or Avg(Field)

... Let me know

Not applicable
Author

It's the same field, but I want to use different aggr function depending on the measurement unit

if(wildmatch(UnitDesc, '*xyz*') = 0,

sum(Measurement),

avg(Measurement)

)

alexandros17
Partner - Champion III
Partner - Champion III

The syntax seems correct, could you send your document telling what's wrong?

Thanks

anbu1984
Master III
Master III

Can you post sample app or current output and expected output?

Not applicable
Author

Nevermind, I had the wrong field-name in my expression. Need to be more careful when having similiar field names in my document.