Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
confused-pandas
Contributor II
Contributor II

Selecting field value based on other selection field

Hi,

I am trying to make a bar chart where I compare two measures. One that is strictly dependent of the selector while the other one is only indirectly dependent of the selector.

Concretely, I have a selector where I can select a client. The first measure calculates the average of some field for the given selection. What I want to do in the second measure is to ignore the customer selection but instead filter based on the business sector of the customer selected.

My question: how can I, in the set analysis, express that I want to select the business sector of the customer that was selected with the selector without selecting the customer himself? 

Any idea how I can do this? Much appreciated!

1 Solution

Accepted Solutions
confused-pandas
Contributor II
Contributor II
Author

I might have found the solution. For anyone interested 

=avg({<CustomerName=, CustomerIndustry = {`$(=ONLY({<CustomerName = {"$(=GetFieldSelections(CustomerName))"}>} CustomerIndustry ))`}>} YourMeasure)

The "CustomerName=" part ignores the selection
The {`$(=ONLY({<CustomerName = {"$(=GetFieldSelections(CustomerName))"}>} CustomerIndustry ))`} part get the industry of the selected customer

View solution in original post

2 Replies
confused-pandas
Contributor II
Contributor II
Author

I might have found the solution. For anyone interested 

=avg({<CustomerName=, CustomerIndustry = {`$(=ONLY({<CustomerName = {"$(=GetFieldSelections(CustomerName))"}>} CustomerIndustry ))`}>} YourMeasure)

The "CustomerName=" part ignores the selection
The {`$(=ONLY({<CustomerName = {"$(=GetFieldSelections(CustomerName))"}>} CustomerIndustry ))`} part get the industry of the selected customer

GaryGiles
Specialist
Specialist

You can use the element function P() to accomplish what you are looking for in your second measure.  In your set analysis,

{$<[Client]=,[BusinessSector]=P([BusinessSector])>}

[Client]= will cause the measure expression to ignore the selection in the [Client] field.  P([BusinessSector]) returns the possible values for [BusinessSector].  The P function doesn't ignore the selection in [Client], so it will return the [BusinessSector] for the client selected.