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: 
Ethel
Creator III
Creator III

calculate max value and put name of that value in the title

Hello,

I have graph that represents age distribution. For 2022 max age is 'grey age' (20-30),21.2%.

I need to put this information in the title. I have a set analysis formula, that calculates 21.2% correctly. But how can I put  (20-30)in the title?

Just in case my set analysis formula for the age is 

=num(
max(
aggr({<Parametr={'Y'}>}
avg({<Parametr={'Y'}>}
aggr({<Parametr={'Y'}>}
sum({<HParametr={'Y'}>}[HeadCount]),[Period], Age)), Age)
)
/
avg(aggr({< Parametr={'Y'}>}
sum( {< Parametr={'Y'}>}[HeadCount]),[Period]))
,'#,##0.0%')

 

Ethel_0-1655901247434.png

Thanks a lot in advance!

Labels (5)
2 Solutions

Accepted Solutions
Or
MVP
MVP

Generally speaking, the function you'd use to do this is FirstSortedValue(Age,FormulaForSorting).

View solution in original post

Ethel
Creator III
Creator III
Author

I'm getting "error nested aggregation not allowed". I tried to create master measure, but it this function doesn't see it)

View solution in original post

6 Replies
Or
MVP
MVP

Generally speaking, the function you'd use to do this is FirstSortedValue(Age,FormulaForSorting).

Ethel
Creator III
Creator III
Author

should I put this?

FirstSortedValue(Age,

num(
max(
aggr({<Parametr={'Y'}>}
avg({<Parametr={'Y'}>}
aggr({<Parametr={'Y'}>}
sum({<HParametr={'Y'}>}[HeadCount]),[Period], Age)), Age)
)
/
avg(aggr({< Parametr={'Y'}>}
sum( {< Parametr={'Y'}>}[HeadCount]),[Period]))
,'#,##0.0%')).

Ethel
Creator III
Creator III
Author

I'm getting "error nested aggregation not allowed". I tried to create master measure, but it this function doesn't see it)

Or
MVP
MVP

I wasn't really able to follow along with that formula as it pertains to your requirement, unfortunately, so I'm not sure if you'd need to apply it as-is or modify it (and if so, in what way).

Ethel
Creator III
Creator III
Author

set analysis formula works correctly. 

But when I'm trying to apply FirstSortedValue, it doesn't work with set analysis. Is there any other way I can achieve my goal?

Thank you very much in advance!

Ethel
Creator III
Creator III
Author

Thank you, it worked! I added aggr.

Thank you so much!