Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
May 18th 10AM ET, Live Chat, bring your QlikView questions. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis - Setting a field equal to another field's selection

Is it possible to set a field equal to another field's selection using set analysis?

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

Try this, should work

sum({<Field2=P(Field1)>} Count1)

View solution in original post

13 Replies
swuehl
MVP
MVP

Have you tried

{<FieldA = FieldB >}

?

Not applicable
Author

I'm working on the expression that when I select in Field1 it will use the value of that selection in Field2 in the expression.  Field 2 table is a subset of Field1 table.  I was thinking of this expression but it does not work.

sum({<Field2=Field1>} Count1)

swuehl
MVP
MVP

How are your three fields related in your data model? Could you upload a small sample app?

Not applicable
Author

To explain further, here's where I am now.

sum({$<Field2= {"John"}>} Count1)

I want that "John" to be the selected value of Field1.

Clever_Anjos
Employee
Employee

Try this, should work

sum({<Field2=P(Field1)>} Count1)

View solution in original post

gabriel_kirst
Creator III
Creator III

What about trying to set the selected value in Field1 into a Variable, and use this variable in set analysis?

The variable would be somethig like this:

vField1 = GetFieldSelections(Field1)

And the set analysis, using this variable:

sum({$<Field2= {$(vField1)}>} Count1)


Regards,

Gabriel

Not applicable
Author

This worked perfectly.  Can you explain a bit what the P does.  Sorry, I'm a beginner.

Not applicable
Author

From the help window:

There is however an additional way to define a set of field values by the use of a nested set definition.

In such cases, the element functions P() and E() must be used, representing the element set of possible values and the excluded values of a field, respectively. Inside the brackets, it is possible to specify one set expression and one field, e.g. P({1} Customer). These functions cannot be used in other expressions:

Examples:

sum( {$<Customer = P({1<Product={‘Shoe’}>} Customer)>} Sales )
returns the sales for current selection, but only those customers that ever have bought the product ‘Shoe’. The element function P( ) here returns a list of possible customers; those that are implied by the selection ‘Shoe’ in the field Product.

Not applicable
Author

I end up using Clever's solution since I don't have to use variable.  Thanks for the help anyway.