Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
abohorquez
Contributor II
Contributor II

Change comparison String with a Variable in a chart

Hi Qlik community, I'm new here

I'm trying to do this in a chart

When I use a string in a counter

      Count({<[Gerencia]={'Abogados'},FecEval={'1/10/2018'},[Cla1]={'Abogado'}>} Sexo)

The counter works great.   but, when I change '1/10/2018' with a variable (vAñoMaximo) dont work

Variable definition:

      vAñoMaximo=if(GetSelectedCount(FecEval)=0,Max(FecEval),GetFieldSelections(FecEval))

I try with this options without a good result

  1. Count({<[Gerencia]={'Abogados'},FecEval={vAñoMaximo},[Cla1]={'Abogado'}>} Sexo)
  2. Count({<[Gerencia]={'Abogados'},FecEval={$(vAñoMaximo)},[Cla1]={'Abogado'}>} Sexo)
  3. Count({<[Gerencia]={'Abogados'},FecEval={text(vAñoMaximo)},[Cla1]={'Abogado'}>} Sexo)
  4. Count({<[Gerencia]={'Abogados'},FecEval=text(vAñoMaximo),[Cla1]={'Abogado'}>} Sexo)
  5. Count({<[Gerencia]={'Abogados'},FecEval=date(vAñoMaximo),[Cla1]={'Abogado'}>} Sexo)
  6. Count({<[Gerencia]={'Abogados'},FecEval=date(vAñoMaximo, 'DD/MM/YYYY'),[Cla1]={'Abogado'}>} Sexo)
  7. Count({<[Gerencia]={'Abogados'},FecEval=date($(vAñoMaximo), 'DD/MM/YYYY'),[Cla1]={'Abogado'}>} Sexo)
  8. etc...

I hope you can help me.

1 Solution

Accepted Solutions
abohorquez
Contributor II
Contributor II
Author

That's exactly the question... I tried to many permutations of code to convert the data without a good result...

I solve the issue creating a new field with a tag of the last date compared.

Thx for your time.

View solution in original post

5 Replies
MarioCenteno
Creator III
Creator III

Podrías intentar algo así

LET vMaxYear = Year(Today() );


Count({<[Gerencia]={'Abogados'},FecEval={'vMaxYear' },[Cla1]={'Abogado'}>} Sexo)


Or



Load

Year(date) as Year

Select * from table;


Expression

Count({<Gerencia]={'Abogados'},Cla1={'Abogado'}, year= {$(=max(Year))}>}Sexo)

Vegar
MVP
MVP

Take a look at the output of your variable vAñoMaximo. You need to make it to contain the date presented as text and not an integer.


SET modifiers always evaluate against the string part of an dual.  A date field (eg FecEval) consist of a string and a numeric value. Your date 1/10/2018 is the string representation of the numeric value 43374.


There is a important diffrence between the two expressions below.

Count({<[Gerencia]={'Abogados'},FecEval={'1/10/2018'},[Cla1]={'Abogado'}>} Sexo)

Count({<[Gerencia]={'Abogados'},FecEval={'43374'},[Cla1]={'Abogado'}>} Sexo)

abohorquez
Contributor II
Contributor II
Author

That's exactly the question... I tried to many permutations of code to convert the data without a good result...

I solve the issue creating a new field with a tag of the last date compared.

Thx for your time.

abohorquez
Contributor II
Contributor II
Author

Gracias mario pero en efecto el tema es como lo menciona el colega Vegar, es un tema de comparación dado que la fecha puede ser vista como un número equivalente... sin embargo realicé varias permutaciones para transformar y homogeneizar la data  sin exito.   Lo solucioné creando un campo en el que se registra la ultima fecha comparada.

Gracias por tu tiempo.

Vegar
MVP
MVP

Glad to help.

Please mark the issue as answered for future reference.