Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
mp802377
Creator II
Creator II

My average in Pivot Table is not correct

I have this example table below.

    

IDStart Date/TimeCategoryMTRDuration
128-Jan-16 19:19AR02:132:13:00
225-Jan-16 09:12AR00:540:54:00
314-Jan-16 09:31AR00:400:40:00
413-Jan-16 23:06AR01:041:04:00
512-Jan-16 22:45AR01:171:17:00
612-Jan-16 10:01AR01:121:12:00
707-Jan-16 22:25AR01:061:06:00
803-Jan-16 03:00AR07:157:15:00

If you take this table in Excel and do an average of MTR, the average is 01:57. In Qlikview my dimensions are category and MonthYear. My expression is Avg(MTTR) and I also tried (Sum(MTTR))/(Count(MTTR)) and it comes to 01:53. That is a difference of 4 minutes. All of my averages are off 3-7 minutes.  I tried Aggr(Avg(MTTR),category) and came up with the same number. I don't like that though because when I remove 2016, it does an aggregation of all years and I want year over year or month over month depending on the chart. What am I doing wrong?

1 Solution

Accepted Solutions
mp802377
Creator II
Creator II
Author

I found my problem. It is the little things behind the scenes that will always get you. In my load statement, I have a join and that was multiplying my distinct ID. So, of course, my average was not providing the correct answer. Fixed the join (just created it as a separate table instead of a join) and that fixed that. An entire day on a little thing behind the scenes.....

I really wasn't trying to take an average of an average. My first was avg(MTTR), but that didn't work, nor anything else. I was grasping at straws. Now avg(MTTR) works.

View solution in original post

6 Replies
mp802377
Creator II
Creator II
Author

The column name is actually MTTR, above I typed it in.

johnw
Champion III
Champion III

Assuming you want the average of the averages instead of just the overall average, you'd need to list all your dimensions in the aggr, not just one of them. So I believe you want this?

avg(aggr(avg([MTTR]),[Category],[MonthYear]))

Though if you have both year over year and month over month for this data, those two charts are likely to have different average of averages. Are you sure you want the average of averages and not just the average?

mp802377
Creator II
Creator II
Author

That formula is still giving me the 1:53, which is not correct. it needs to be 1:57.

johnw
Champion III
Champion III

For the data you posted, both a simple average and my average of averages formula (since there's only a single average) create the same value in QlikView, 01:57. If you can post data that duplicates the problem, perhaps I can help further. But without being able to duplicate your problem, it's very hard to solve your problem.

Capture.PNG

mp802377
Creator II
Creator II
Author

I found my problem. It is the little things behind the scenes that will always get you. In my load statement, I have a join and that was multiplying my distinct ID. So, of course, my average was not providing the correct answer. Fixed the join (just created it as a separate table instead of a join) and that fixed that. An entire day on a little thing behind the scenes.....

I really wasn't trying to take an average of an average. My first was avg(MTTR), but that didn't work, nor anything else. I was grasping at straws. Now avg(MTTR) works.

johnw
Champion III
Champion III

Glad you figured it out.