Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
mrjohn23
Contributor III

Avg Multiple conditions in chart and script

Hello, I'm having trouble with the syntax to avg multiple values.

I have the below values and I want to exclude VTO and UTPO values in my avg expression. I would like to see both in chart and in script...Thanks in advance.

Reasons

OT

PTO

VTO

UTPO

=avg(if(REASON = '',''))

1 Solution

Accepted Solutions

Re: Avg Multiple conditions in chart and script

May be this:

=Avg({<REASON -= {'VTO', 'UTPO'}>} FieldName)

or

=Avg({<REASON ={'*'}-{'VTO', 'UTPO'}>} FieldName)

8 Replies

Re: Avg Multiple conditions in chart and script

May be this:

=Avg({<REASON -= {'VTO', 'UTPO'}>} FieldName)

or

=Avg({<REASON ={'*'}-{'VTO', 'UTPO'}>} FieldName)

Partner
Partner

Re: Avg Multiple conditions in chart and script

Hi,

Can you please share some more details and add some sample app/output you are expecting.

mrjohn23
Contributor III

Re: Avg Multiple conditions in chart and script

What would the FieldName be in my case?

Re: Avg Multiple conditions in chart and script

Whatever you are trying to Avg

mrjohn23
Contributor III

Re: Avg Multiple conditions in chart and script

I have a column "Reasons" that has about 30 values within that column. I want to avg only certain values within the Reasons column.

Column                                                      

Reasons                                                ID (thds of values)                   Value

OT (include in AVG)                               1                                              10

PTO (include in AVG)                            2                                                20

VTO (exclude in AVG)                           3                                               30

UTPO (exclude in AVG)                         4                                              40

Output

AvgReasons

Partner
Partner

Re: Avg Multiple conditions in chart and script

Hi,

Use below expression.

=Avg({<REASON -= {'VTO', 'UTPO'}>} Value)

mrjohn23
Contributor III

Re: Avg Multiple conditions in chart and script

Got it! One more question

I have two conditions that I need met. The 2nd, Status = Closed. Can that be added in the expression?

=Avg({<DISCHARGE_REASON ={'','','','','',''}>}DAYS)

Re: Avg Multiple conditions in chart and script

May be this:

=Avg({<REASON -= {'VTO', 'UTPO'}, Status = {'Closed'}>} Days)