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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
alexdelagarza
Contributor III
Contributor III

Prior Year variable not calculating

Hello,

Can anybody help me? 

I need to create a table to compare the current year (or selected) versus the prior year, I'm using the variable: Año={$(=Max(Año)-1)}, it works in other reporte that I have, but it doesn't in this one, I'm wondering if it isn't working due to in this case I'm using an aggregated function.

For the current year (in the case of Light vehicles or "Ligeros"), I'm using the following expression:

=Sum(AGGR(COUNT({<AGRUPACION_LP={'Ligeros'}>}ID_TRANSIT)*POND_TOTAL, FECHAT, PROYECTO, DESCRIPCION))/COUNT({<DUE={'1'}>}Día)

And, for the prior year I'm using the following:

=Sum(AGGR(COUNT({<Año={$(=Max(Año)-1)},AGRUPACION_LP={'Ligeros'}>}ID_TRANSIT)*POND_TOTAL, FECHAT, PROYECTO, DESCRIPCION))/COUNT({<DUE={'1'}>}Día)

This is the table:

alexdelagarza_0-1589307342853.png

 

Thanks in advance

 

 

 

 

 

 

1 Solution

Accepted Solutions
sunny_talwar

May be try this

=Sum({<Año = {$(=Max(Año)-1)}>} Aggr(Count({<Año = {$(=Max(Año)-1)}, AGRUPACION_LP = {'Ligeros'}>} ID_TRANSIT) * Only({<Año = {$(=Max(Año)-1)}>} POND_TOTAL), FECHAT, PROYECTO, DESCRIPCION))/COUNT({<DUE = {'1'}, Año = {$(=Max(Año)-1)}>} Día)

 

View solution in original post

3 Replies
sunny_talwar

May be try this

=Sum({<Año = {$(=Max(Año)-1)}>} Aggr(Count({<Año = {$(=Max(Año)-1)}, AGRUPACION_LP = {'Ligeros'}>} ID_TRANSIT) * Only({<Año = {$(=Max(Año)-1)}>} POND_TOTAL), FECHAT, PROYECTO, DESCRIPCION))/COUNT({<DUE = {'1'}, Año = {$(=Max(Año)-1)}>} Día)

 

alexdelagarza
Contributor III
Contributor III
Author

Great!

Thanks

alexdelagarza_0-1589315515001.png

 

sunny_talwar

Awesome, glad it worked.