Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
nenadvukovic
Creator III
Creator III

What I am doing wrong do get a correct Average and Median in QV?

Hi,

I hope someone can help me out here. I do not get correct Average and Median numbers for a simple case of two prices in 8 rows.

For example:

Date          Price

04.01.2016 70.88

14.01.2016 70.88

20.01.2016 70.88

21.01.2016 70.88

08.02.2016 68.60

22.02.2016 68.60

07.03.2016 68.60

14.03.2016 68.60


and I get an Average of 69.67 and Median of 68.60 instead of 69.74 for both.


I use this expression to get the average: aggr(avg(Price), F1, F2)


Thanks

11 Replies
ali_hijazi
Partner - Master II
Partner - Master II

avg(Price) alone what does it give you?

I can walk on water when it freezes
sunny_talwar

Have you tried straight average?

Avg(Price)


Capture.PNG

nenadvukovic
Creator III
Creator III
Author

The same. I use Aggr()  because I have multiple records in a pivot table.

swuehl
MVP
MVP

I believe it's not useful to discuss a deviation between your expectation and the results if we don't know the setting you are using, e.g. how F1 and F2 relate to Price field.

So please clarify by uploading a small sample QVW.

nenadvukovic
Creator III
Creator III
Author

Yes, I like this as well. It is not that easy as this is only one of tens of objects used in a big QVapp.

I'll see

nenadvukovic
Creator III
Creator III
Author

Just a subset of much more dimensions and measures available. Where is the catch?

2016-03-23_12-38-12.jpg

swuehl
MVP
MVP

Hard to tell exactely, but I guess it's the differenc between your transactional average and the average grouped by your dimensions:

Average – Which average?

I believe what you really want is the average based on the Sum(Sales) / Sum(Qty).

nenadvukovic
Creator III
Creator III
Author

Attached is one example with strange output, but in this case the Avg() returns correct number.

swuehl
MVP
MVP

Could you detail what you consider a strange output?

Note that sum(Qty*Price) / Sum(Qty) is using a weight of Qty.