Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikView forum consolidation is complete. Labels are now required. LEARN ABOUT LABELS
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

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

Sum or Avg of which field?

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

... Let me know

Not applicable

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

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

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