Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Average of 2 or more variables

Hi all,

Who knows how to calculate average of 2 or more variables in a script or an expression?

Thanks in advance,

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I think you want to have a look at the rangeavg() function. Could be used like

LOAD

A,

B,

rangeavg(A,B) as Average

from ...

Or

rangeavg( $(vVal1), $(vVal2) )

Hope this helps,

Stefan

View solution in original post

7 Replies
swuehl
MVP
MVP

I think you want to have a look at the rangeavg() function. Could be used like

LOAD

A,

B,

rangeavg(A,B) as Average

from ...

Or

rangeavg( $(vVal1), $(vVal2) )

Hope this helps,

Stefan

Anonymous
Not applicable
Author

You'are right.

I used rangeavg in an expression, didn't work.

Thanks,

Anonymous
Not applicable
Author

Stefan,

How does the second method work?

Regards,

swuehl
MVP
MVP

Well, it works using QV variables.

I wasn't sure what you mean with variables, since some people (like in statistics) use the term variable different from the QV usage, where it is used like in software programming (variable in contrast to constant). The term variable used in statistics would be called field or dimension / measure in QV.

Since I don't know what you are after, I posted short samples for both (maybe too short samples). So $(vVal1) and $(vVal2) evaluate the QV variables vVal1 and vVal2 respectively.

But if this does not solve your probelm, it would be more important to know what you are after, what your requirements / problems are?

Anonymous
Not applicable
Author

Thanks,

I found out.

kavicsgym
Creator
Creator

Hi, do you think it can be used to define the value of a reusable expression like that?

It does not work in Sense variable editor.

RangeAvg( 

                 $(eKPI(06)), $(eKPI(07))

                   )

The values are monthly figures and their average should be calculated.

Thanks , Enikö

kavicsgym
Creator
Creator

Hi, could anyone pls. resolve my question from some month ago, I found a workaround but this would be nicer:

RangeAvg(20, 40)  is the definition or my variable in Qlik sense, it works

But with a nested expression it does not work, can anyone suggest pls why?

RangeAvg    

  $(ePDCA_WSAuslief_Pkd_Total(01)), $(ePDCA_WSAuslief_Pkd_Total(02))

     )

Those 2 expressions are complicated enough... how could I pass their value to RangeAvg?????

Thanks a lot! Enikö