Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problems with the average of an expression

I want to calculate the average of this expression (below).

(Sum({$<[Bokslut (KSEK)]={'Resultat efter finansnetto'}>} Bokslut)) /

(sum({$<[Bokslut (KSEK)]={'Omsättning'}>} Bokslut))

I need the average of the total. I have tried a lot of different varieties with TOTAL and Avg. Avg(TOTAL.......). But with no success!

2 Replies
matt_crowther
Luminary Alumni
Luminary Alumni

I amy be missing something but I'd try:

((Sum({$<[Bokslut (KSEK)]={'Resultat efter finansnetto'}>} Bokslut)) / (sum({$<[Bokslut (KSEK)]={'Omsättning'}>} Bokslut))) /

((count({$<[Bokslut (KSEK)]={'Resultat efter finansnetto'}>} Bokslut)) +

(count({$<[Bokslut (KSEK)]={'Omsättning'}>} Bokslut)))

Simply the sum of your expression divided by the number of values that are contained in that expression.

Hope that helps,

Matt - Visual Analytics Ltd

Not applicable
Author

Hi,

Have you tried using the aggr() function to get an average. Something like -

Avg(aggr((Sum({$<[Bokslut (KSEK)]={'Resultat efter finansnetto'}>} Bokslut)) /

(sum({$<[Bokslut (KSEK)]={'Omsättning'}>} Bokslut)),SomeField))

You will need to replace the 'SomeField' value with an appropriate field to aggregate over.

I hope this helps

Thanks

Nick