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

Expression having sum of few avg based on where clause

Hi Experts,

Please find below few sample records:

YearStringSubfield(String,'-',5)Ratio
20072007-Q1-3-4-YR1YR12
20072007-Q1-2-4-YR1YR13
20072007-Q1-2-5-YR2YR24
20072007-Q1-7-4-YR3YR31
20072007-Q1-2-5-YR3YR32
20072007-Q1-9-4-YR2YR25

Now I need to calculate the following:

= sum of (avg(ratio) where Subfield(CFYStr,'-',5)='YR1' + avg(ratio) where Subfield(CFYStr,'-',5)='YR2' +avg(ratio) where Subfield(CFYStr,'-',5)='YR3' )

I need this in the expression of a line chart. I am not able to do this.

Any help would be highly appreciated.

Thanks in advance.

Regards

1 Reply
sunny_talwar

May be create the subfield field in the script:

Table:

LOAD Year,

     String,

     SubField(String,'-',5) as Dimension,

     Ratio

FROM

[https://community.qlik.com/thread/186294]

(html, codepage is 1252, embedded labels, table is @1);

and then use the following expression: =Sum(Aggr(Avg(Ratio), Dimension))