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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

AVG Group By

SOS, I could not find the syntax error or process that does not allow me to calculate:

avg (ies_AñosAcreditacion) * 100 as ies_AñosAcreditacionVariacion2

Thank you

--------------------------------------------------------------------------------

IES_Indicadores:

LOAD *

FROM $(PathQVD)IES_Detalles.QVD

(qvd);

ES_Indicadores2:

LOAD

     ies_Version,

     ies_Codigo,

     ies_Nombre,

     ies_Nemonico,

     ies_Agrupacion,

     ies_SubAgrupacion,

     ies_Regionales,

     ies_AdscritasAdmision,

     ies_AñosAcreditacion,

     avg(ies_AñosAcreditacion) * 100 as ies_AñosAcreditacionVariacion2

Resident IES_Indicadores Group By ies_Version;

Captura_qv.PNG

Labels (1)
2 Replies
diego_a_barboza
Creator
Creator

You need to group your data, otherwise it will not be capable to show the average.

ES_Indicadores2:

LOAD

     ies_Version,

     ies_Codigo,

     ies_Nombre,

     ies_Nemonico,

     ies_Agrupacion,

     ies_SubAgrupacion,

     ies_Regionales,

     ies_AdscritasAdmision,

     ies_AñosAcreditacion,

     avg(ies_AñosAcreditacion) * 100 as ies_AñosAcreditacionVariacion2

Resident IES_Indicadores Group By ies_Version

group by

     ies_Version,

     ies_Codigo,

     ies_Nombre,

     ies_Nemonico,

     ies_Agrupacion,

     ies_SubAgrupacion,

     ies_Regionales,

     ies_AdscritasAdmision,

     ies_AñosAcreditacion;

An alternative would be creating an auxiliar table with the averages... however, in my humble opinion, it's much better to let QlikView calculate the average on the object itself (chart/table/etc...)

swuehl
Champion III
Champion III

You need to list all LOADed fields in the GROUP BY clause that are not aggregated (or remove them from the LOAD or aggregate them):

ES_Indicadores2:

LOAD

     ies_Version,

     ies_Codigo,

     ies_Nombre,

     ies_Nemonico,

     ies_Agrupacion,

     ies_SubAgrupacion,

     ies_Regionales,

     ies_AdscritasAdmision,

     ies_AñosAcreditacion,

     avg(ies_AñosAcreditacion) * 100 as ies_AñosAcreditacionVariacion2

Resident IES_Indicadores

Group By ies_Version,

     ies_Codigo,

     ies_Nombre,

     ies_Nemonico,

     ies_Agrupacion,

     ies_SubAgrupacion,

     ies_Regionales,

     ies_AdscritasAdmision,

     ies_AñosAcreditacion

;