Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
wanyunyang
Contributor II

Average function is not giving correct result

Hi everyone,

In a straight table I'm using avg(TimeStamp1-TimeStamp2) as measure, but the total is not showing me correct average. 

avg.PNG

In this case the total should be 0.462, but it's showing me 0.455. Any idea on this? Anything helps! Thanks in advance! 

 

1 Solution

Accepted Solutions
zzyjordan
Contributor II

Re: Average function is not giving correct result

Hi,
It seems you have multiple records for each of your dimension value, and the total you expected is actually an average of your average per your dimension value, so you need something like nested aggregation, and you should use aggr() in your expression in this case.
If you could share some dummy data but with similar data structure as your real one, it will be easier to show how to achieve it.

ZZ
3 Replies
radmin5253
New Contributor III

Re: Average function is not giving correct result

created a quick test on using the following inline load statement and when I do AVG(Y) in a kpi I get 0.462

T1:
Load * Inline [
X|Y
1|0.44041667
2|0.48364583] (delimiter is '|');

Do you see something different when you use this simple load script.

zzyjordan
Contributor II

Re: Average function is not giving correct result

Hi,
It seems you have multiple records for each of your dimension value, and the total you expected is actually an average of your average per your dimension value, so you need something like nested aggregation, and you should use aggr() in your expression in this case.
If you could share some dummy data but with similar data structure as your real one, it will be easier to show how to achieve it.

ZZ
wanyunyang
Contributor II

Re: Average function is not giving correct result

You are right, I got the issue and solved it. Thanks for helping!