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: 
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
Specialist
Specialist

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