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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
motzfeldt01
Partner - Contributor II
Partner - Contributor II

Combing IF-statement with Aggr()

Hi,

I'm using the code below to identify the top five performers and now I want get the average of those top five performers.

If(Rank(TOTAL SUM({$<

[CompanyName]=,

[XBRL Reporting year]={$(vXBRLThisYear)},

industry={$(vChosenIndustry)}>}

[Årets resultat]))<=5,

SUM({$<

[CompanyName]=,

[XBRL Reporting year]={$(vXBRLThisYear)},

industry={$(vChosenIndustry)}>}

[GrossResult]))

I have tried an aggr() function, but have not managed to succeed.

Does anyone have idea how to get the average value of top 5?

1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

This isn't working?

Avg({$<[CompanyName], [XBRL Reporting year] = {$(vXBRLThisYear)}, industry={$(vChosenIndustry)}>} Aggr(

If(Rank(TOTAL SUM({$<[CompanyName], [XBRL Reporting year] = {$(vXBRLThisYear)}, industry = {$(vChosenIndustry)}>} [Årets resultat])) <= 5, Sum({$<[CompanyName], [XBRL Reporting year] = {$(vXBRLThisYear)}, industry = {$(vChosenIndustry)}>} [GrossResult]))

, Performer))

View solution in original post

4 Replies
sunny_talwar
MVP
MVP

This isn't working?

Avg({$<[CompanyName], [XBRL Reporting year] = {$(vXBRLThisYear)}, industry={$(vChosenIndustry)}>} Aggr(

If(Rank(TOTAL SUM({$<[CompanyName], [XBRL Reporting year] = {$(vXBRLThisYear)}, industry = {$(vChosenIndustry)}>} [Årets resultat])) <= 5, Sum({$<[CompanyName], [XBRL Reporting year] = {$(vXBRLThisYear)}, industry = {$(vChosenIndustry)}>} [GrossResult]))

, Performer))

motzfeldt01
Partner - Contributor II
Partner - Contributor II
Author

Unfortunately not. No value is shown. But I don't understand where 'Performer' comes from?

sunny_talwar
MVP
MVP

It came from your description of the problem

Capture.PNG

I guess Performer is not a field name, but is rather called something else... replace Performer with the field which shows performers

motzfeldt01
Partner - Contributor II
Partner - Contributor II
Author

It worked!! Thank you very much and have a nice day 🙂