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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

asking about Average

hi all

I wanna ask something about average in QV coz I have trouble about it.

I have a pattern to get UA value. the patters like this

UA = (P) / (O + P)

I have 5 UA value in decimal number:

UA1 = 80/744 = 10,75

UA2 = 1/384 = 0,26

UA3 = 15/744 = 2,01

UA4 = 50/744 = 6,72

UA5 = 62/744 = 8,33

If I calculate it with manual condition it will be like this (10,75 + 0,26 + 2,01 + 6,72 + 8,33)/5 = 28,07/5 = 5,61

but when I try with Qlikview I get different avg value. the value is 6,91.

when I trace it with this expression:

          =avg(aggr(((sum(ProductiveRelated))/(sum(OperatRelated) + sum(ProductiveRelated)))*100,EquipType))

I will get the value is 6.91.

the value 6.91 comes from different patter in qlikview. the pattern that I get is ((80+1+15+50+62)/5)/((744+384+744+744+744)/5) = 6,91

what I need to know is how to get value like manual condition in qlikview, Can you help me guys??

note: P and O value are different table.

thanks before

ardo

7 Replies
tresesco
MVP
MVP

Could you upload your sample qvw that shows the issue?

Not applicable
Author

my qvw data connect with database mysql and I get difficult to explain it

but with a simple explenation  the calculation is like this

normal pattern is :

UA = (P) / (O + P)

so if I try to find the avg of UA  then the pattern to get avg is :

avg UA = sigma((P)/(O+P))/count UA.

my difficulty is how to put it on qlikview

thank u

tresesco
MVP
MVP

Try to create a sample qvw and ipload here explaining the expected output. Otherwise, I guess your :

sigma((P)/(O+P))/count UA, could be something like: =Sum(P/(O+P))/count (Distinct UA)

Note: 'Distinct' might/might not be required based on your logic.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

The difference is because QV is calculating the ratio of the sums, which is not the same as the sum of the ratios (which is what you require).

if you are doing this in a straight table, select Sum of Rows in the Total Mode (Properties | Expression). If you are using a pivot table, then use an aggr() expression like this:

= Sum(Aggr(Sum(P) / (Sum(O) + Sum(P)), <your chart dimensions>))

Where <your chart dimensions> should be a comma separated list of the dimensions in your chart.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
hic
Former Employee
Former Employee

I think you are complicating it...

If you make a chart with

     Dimension: EquipType (your UA1..UA5)

     Expression: Avg(ProductiveRelated/(OperatRelated+ProductiveRelated))/Count(distinct EquipType)

then I think you will get both the individual averages and the total right.

HIC

lironbaram
Partner - Master III
Partner - Master III

have a look at the attach example

Not applicable
Author

Hi All

thanks for all of your input to me. jonathan dients, thanks for your ideas...I ve explore it n I found solution for my

trouble...this is what I get

=(sum(aggr(sum(ProductiveRelated),Plant_No)/(aggr(sum(OperatRelated),Plant_No) + aggr(sum(ProductiveRelated),Plant_No))*100)/count(DISTINCT Plant_No))

ProductiveRelated,OperatRelated they are consist of 2 table with the same plant_No. so I use this solution

I Hope this pattern can be useful for us in future

thanks

ardo