Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Hoowling
Contributor III
Contributor III

Using variable in expression

Hi community, 

I'm trying to get the following expression to work

=Avg({<[Bolag]=,[Info Bransch]=P({$} [Info Bransch])>}[$(=varLönsamhet)])

where I want to calculate the average selected KPI from a list box for companies in the same sector as the selected one (Bolag = Company, Info Bransch = Sector). The KPI selected is captured in the varLönsamhet variable but how do I properly include the variable in the expression? Right now I get an error message. 

Thank you! 

Cheers,
Philip 

Labels (3)
1 Reply
jonathandienst
Partner - Champion III
Partner - Champion III

Like this:

=Avg({<[Bolag], [Info Bransch] = P({$} [Info Bransch])>} $(varLönsamhet))

Assuming the variable varLönsamhet does not include an aggregation like Sum() or Count().

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein