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

SetExpression using variables not ignoring Current Selecion

Hi all,

I have two Variables to calculate a result, its like this:

vResultReal =

   if(TipoAcumulo='Soma',

      sum(RealizadoIndicadores)/sum(MetaIndicadores),

      if(TipoAcumulo='Media',

         avg(ResultadoIndicador),

         sum( IF(MesAnoBSC=$(vMaxMesAno), ResultadoIndicador))

      )

   )

and

vResult = Aggrif($(vResultReal)>1.5,1.5,$(vResultReal)) * PesoIndicador    , TipoAcumulo, Indicador)

Ok, now on the dashboard I have two buttons, and there text are a formula using vResult

Button text1 = =Sum({<Objetivo={'Aumentar valor para o acionista'}>}$(vResult))

Button text2 = =Sum({<Objetivo={'Gerir despesas'}>} $(vResult))

They're only difference is the filter. 

Now, here goes the problem:

We I click each button, the field Objetivo needs to be selected depending on the clicked button.

And this make the button not clicked to show "0". The text on the buttons cannot change based on the selected Objetivo.

The QVW is attached, can anyone help please.

Rogério Faria

Brazil

2 Replies
stephencredmond
Luminary Alumni
Luminary Alumni

Hi,

You probably should use separate expressions and variables for this.  The problem is that the Set expression also needs to be in the expressions controlled by the variables.  That is why it zeros when you make a selection.

Regards,

Stephen

Not applicable
Author

Thanks for the answer,

But this is the problem.

I have in this example 2 buttons only, and I will need to create more than 30 buttons (the objectives from our bussiness plan).

So I'd like a way to reuse the expression, changing only the SetExpression.

I also tried something like that, in hope it would consider the previous SetExpression: ({$<Objetivo=>})

vResultReal =

   if(TipoAcumulo='Soma',

      sum({$<Objetivo=>}RealizadoIndicadores)/sum({$<Objetivo=>}MetaIndicadores),

      if(TipoAcumulo='Media',

         avg({$<Objetivo=>}ResultadoIndicador),

         sum({$<Objetivo=>}IF(MesAnoBSC=$(vMaxMesAno), ResultadoIndicador))

      )

   )

But it didnt work.

Grateful If any others ideia,

Rogério Faria