Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Hoowling
Contributor III
Contributor III

Change chart expression based on selection

Hi community! 

I would like alter the chart expression based on the list box selection made. 
The expression I would like to be dynamic is: 

=Avg({<[Info Bransch]=P({$} [Info Bransch])>}[EBIT-marg Senaste])

Where [EBIT-marg Senaste] should change given my selection in the list box (EBIT-marg Senaste is a dimension). 

THankful for any help!

12 Replies
chrismarlow
Specialist II
Specialist II

Hello again,

In this case the set analysis/P() seems redundant, you use that where you need to do something more complex based on selections on another field or having 'cancelled' selections on another field (which is what you other thread was doing).

Curious that EBIT-marg Senaste is both a dimension and a measure (since you are taking an average) - although is possible in Qlik.

May be easier with a picture of what you would like to happen & a small chunk of sample data.

Cheers,

Chris.

Hoowling
Contributor III
Contributor III
Author

The P()function is used in this case to generate the average EBIT-margin for all the peers of the selected company, i.e. companies with the same "info bransch" as the selected company.  

In the below picture, I would like to change the values of the chart table (red arrow) based on the list box selection (red circle). I've also pasted a picture of my data. 

Snipaste_2019-02-16_13-10-47.png

Hoowling
Contributor III
Contributor III
Author

Snipaste_2019-02-16_13-14-52.png

chrismarlow
Specialist II
Specialist II

Hi,

Ok. You still need to cancel the selection on company in the set to get the peers, I think looking at your spreadsheet Company is Bolagsnamn, so;

Avg({<Bolagsnamn=,[Info Bransch]=P({$} [Info Bransch])>}[EBIT-marg Senaste])

But looking at your dashboard I think you also need this to be looking at a specific date & the other objects have time series? In which case I think that needs added to the set, depending on how your time series data works.

Cheers,

Chris.

Hoowling
Contributor III
Contributor III
Author

OK, I've included Bolagsnamn in the set. 

The time series can be ignored since this data is gathered from another source and I only have time series data for a very limited number of companies. 

How would you go about making the expression dynamic i.e. changing "EBIT-marg Senaste" to the list box selection?

Regards,
Philip 



chrismarlow
Specialist II
Specialist II

Hi Philip,

What field does that list box look at?

I am slightly lost with your data model. If the EBIT-marg Senaste etc exists both as a member of a field, and the name of a field then you could use a list box on the field it is a member of, to then make a selection and then use a dollar sign expansion to use that in the aggregation expression, so something similar to;

20190216_2.png

20190216_3.png

20190216_4.png

But there are other ways of populating the list box that mean that is not required in the data model & this approach would not work.

Cheers,

Chris.

Hoowling
Contributor III
Contributor III
Author

Quick question before sharing an example file - isn't it possible to replace the "EBIT-marg Senast" text string with a variable? Where the text string generated by the variable changes with a list box selection. 

Cheers,
Philip 

chrismarlow
Specialist II
Specialist II

Hi,

Yes, that is probably where this is going, it is how the variable and the list box interact that is what to work out.

Cheers,

Chris.

Hoowling
Contributor III
Contributor III
Author

Hi, 

I've created a variable (varLönsamhet) that generates the text string I want to replace "EBIT-marg Senaste" with in below statement:

=Avg({<[Bolagsnamn]=,[Info Bransch]=P({$} [Info Bransch])>}[EBIT-marg Senaste])

How do I incorporate the variable in this expression? 

FYI - varLönsamhet = GetFieldSelections(Nyckeltal,true(),true(), 'Lönsamhet')