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

Select Field with two variables

Hi.

In my application I set the variables "Weight From" and "Weight To" and I need to select the AnimalIDs that are within that weight range wite a button Action. As seen in the image

Regards.

Labels (1)
4 Replies
edwin
Master II
Master II

if the ask is to add this business logic in your expression, add it in set analysis:

sum({<WEIGHT={">=$(vWeightFrom)<=$(vWeightTo)"}>}yourmeasure)

spividori
Specialist
Specialist
Author

Hi Edwin.

Thanks for answering.

I need to select the IdAnimal whose weight is within that range.

I had thought of button action.

Regards.

spividori
Specialist
Specialist
Author

I have achieved it through a button action, with the following macro:

Sub Selection
   vFirst= ActiveDocument.Variables("vPesoDesde").GetContent.String
   vLast= ActiveDocument.Variables("vPesoHasta").GetContent.String
   mySelect= ">=" & vFirst & " <=" & vLast
   ActiveDocument.Fields("Peso").Select mySelect
   ActiveDocument.Fields("IdAnimal").SelectPossible
   ActiveDocument.fields("Peso").Clear
end sub

Regards.

edwin
Master II
Master II

if that is the behavior you wanted you can use variable triggers in document settings > triggers
choose teh variables in input add action SELECT FIELD, enter animalID and in expression:
='(' & concat({1<Peso={">=$(vPesoDesde)<=$(vPesoHasta)"}>}IdAnimal,'|') & ')'

when you enter a value in teh variables, the action will trigger.  to test you want to get the values:
(0111|0123|0234) which are the animal IDs where weight is between the two variables