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: 
Not applicable

Using triggers to choose many fields

TableX:

ProductDisplayName

ProductID

I have these two fields above.

I want to use triggers so that when I make selections in ProductDisplayName,

I automatically select their corresponding ProductID, and on top of that,

two additional ProductID's that are not in the field ProductDisplayName.

How can I do this?

1 Solution

Accepted Solutions
Not applicable
Author

Dear Stefan,

Thank you for answering all my questions.

Sincerely,

P

View solution in original post

8 Replies
swuehl
MVP
MVP

If I understood correctly, you could create triggers for field selection / change in document properties with action select in field, and as search string something like

='=sum({<ProductID=p(ProductDisplayName)+{E,F}>} 1)'

where E,F are the two additional field value you want to keep selected.

See also attached.

Regards,

Stefan

Not applicable
Author

What if the two fields are part of the same table?

It's just that I want to be using ProductID as the dimension of a chart,

but ProductDisplayName is the listbox visible to users.

Each ProductDisplayName is linked with one ProductID,

but I want to show two more ProductID's in the chart.

swuehl
MVP
MVP

If the fields are part of the same table, they and their selection states are associated.

If you select one value in ProductDisplayName, you will notice that the associated value in ProductID is possible, all other values are excluded. QlikView won't allow the selection of an excluded value while keeping the original state. So you can't select in ProductDisplayName and then add other values that are logically excluded.

Do you need to keep the ProductDisplayName in the same table? If you are thinking of applying actions to copy the selected values to ProductID anyway, I think it is better to store ProductDisplayName as a data island.

There might be also other approached to achieve what you want, I think we discussed using set analysis in a different thread already?

Not applicable
Author

Hi Stefan,

I see what you mean. Getting the possible values won't allow me to select the other values unless I keep ProductDisplayName as a data island.

Yes, you already helped me with Set Analysis regarding this issue. That worked out pretty nicely. I got the chart I wanted, but one detail is not working properly: color.

My table has these fields:

ProductID, ProductDisplayName, r, g, b

r, g and b are the RGB color values specified for each Product ID. In the chart's expression, I specify the background color =rgb(r,g,b).

Using our example of products A, B, C, D, E, F, with E&F being the two extra items, I can select any of A through D from the ProductDisplayName listbox and the chart will show E and F. However, only A-D show their specified RGB colors. E&F won't show their color properly; instead they show up as black.

sum

(

     {

        ProductID = p(ProductID) + {'E'  , 'F'   },

        ProductDisplayName =,

     }

     Rating

)

If I select E or F from Product, their colors do show up properly. I have no idea why this is happening

That is why I was trying to use triggers instead.

Do you have an idea of perhaps what may be the cause for the set analysis to not get my RGB colors properly?

swuehl
MVP
MVP

you probably need to use the same set expression also for your color attribute expression:

rgb (

only( {< ProductID = p(ProductID) + {'E'  , 'F'   },  ProductDisplayName = >} r),

only( {< ProductID = p(ProductID) + {'E'  , 'F'   },  ProductDisplayName = >} g),

only( {< ProductID = p(ProductID) + {'E'  , 'F'   },  ProductDisplayName = >} b) )

Not applicable
Author

That works. Thanks . I see that set analysis needs to be applied there as well.

What about in the case of line style? How would I use that expression for line styles for this data in a line chart?

Since E & F are added using set analysis, I can't just use the if statement:

     if( ProductID = 'F', '<S2><W1.6>' )

to let the line be a dotted line.

The problem is that I can't quite combine the if statement with set analysis...

Any suggestions on that?

Thanks,

P

swuehl
MVP
MVP

Try  applying the only thing to ProductID.

=if (only( {<...>} ProductID ) =...

Not applicable
Author

Dear Stefan,

Thank you for answering all my questions.

Sincerely,

P