Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count number of register from a field in specified table?

Hello,

I have 3 different tables. In all of them there is a field named "Exp".

In the main table ("Expedientes") is the main key, so the count of this field is what I want to obtain.

But the other 2 tables, there is too a field named "Exp" which is part of their main key.

My problem is that when I calculate the number of "exp" in a graphic, I want only to count the number of "exp" in table "Expedientes" using this expression:

Count([Exp])

But it is counting in the 3 tables...

What can I only obtain the number of "exp" in main table (Expedientes)?

7 Replies
Not applicable
Author

Share your application. There will be much easier if we will be able take a look on your data model.

regards

DArek

Luis_Cortizo
Employee
Employee

Hi, Iñigo

   QlikView doesn't work exactly that way.

Even if you see three different fields in three different tables on the table viewer, that field Exp is only loaded once in memory with all the values from the three tables.

If you want to count the number of occurrences on that field, the best approach would be load a counter of the table. For instance:

Expedientes:

LOAD

    Exp,

    1 as ExpCounter,

    AnotherField,

    AnotherField,

    AnotherField;

[...]

Loading it that way, instead of using a count(Exp) you can use a Sum(ExpCounter) in case all the values are different. If there are repeated values and you need to use a Count(Distinct )

Expedientes:

LOAD

    Exp,

    Exp as ExpCounter,

    AnotherField,

    AnotherField,

    AnotherField;

[...]

And the expression would be count(Distinct ExpCounter).

Hope it helps.

Best regards.

Not applicable
Author

Hola Luis,

Con ese nombre supongo que te puedo escribir en castellano... jeje. Gracias por la respuesta.

Lo del Count me lo imaginada que se haría así, el problema es si después al añadir una dimensión en el gráfico, por ejemplo Año de expediente (contenido en la tabla Expedientes), ¿me los clasificará por este campo, siendo la expresión que se muestra en el gráfico la suma de los expedientes?

jaimeaguilar
Partner - Specialist II
Partner - Specialist II

Hola,

otra cosa que puedes hacer es ponerle una bandera de texto, para después utilizarla en set analysis:

En el script:

TablaPrincipal:

'Indicador tabla principal' as TipoExp, //Ponle cualquier texto sólo como referencia

Exp

from Table;

y después en la expresión de tu gráfica:

count({$<TipoExp={Indicador tabla principal'}>} Distinct Exp)

saludos

Not applicable
Author

You can introduce another field in your table and call it  "Source_Type".  Hard code the table name for this column in load script.

then  write the expression using set analysis:

count({<Source_Type={'Expedientes'}> Exp}

Not applicable
Author

Ok, muchas gracias a todos! Estoy empezando con QlikView... se agradece!

Not applicable
Author

bienvenidos! buena suerte