Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
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
Highlighted

Sum or Avg of which field?

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

... Let me know

Highlighted
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)

)

Highlighted

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

Thanks

Highlighted
Master III
Master III

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

Highlighted
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