Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggr sum and set analysis expression problem

Hi.

I´m having problems with an Aggr expression.

To selected year, it works fine, but when I use the same expression, just switching the set analysis to return resuts to previous year, it doesn´t return values.

Variables are returning the years correctly.

To current year: Aggr(sum({$<Ano={$(vcurrentYear)}>}Aggr(valor, idProdutoReservadoValor,Ano)), [Nome Social]) - This works fine!

To previous Year: Aggr(sum({$<Ano={$(vPreviousYear)}>}Aggr(valor, idProdutoReservadoValor,Ano)), [Nome Social]) - Returns 0.

Any ideas?

Thanks in advance.

Regards,

Bruno Silva.

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

I didn´t understand very well your datamodel.

Check if this expression returns what you need for last year

=sum({$<Ano={$(vAnoAntSeleccionado)}>}Aggr(sum({$<Ano={$(vAnoAntSeleccionado)}>}Aggr(only({$<Ano={$(vAnoAntSeleccionado)}>}valor), idProdutoReservadoValor,Ano)), [Nome Social]))

View solution in original post

10 Replies
MK_QSL
MVP
MVP

If possible please upload your sample file or apps.

Clever_Anjos
Employee
Employee

I think your expression should be:

sum($<Ano={$(vcurrentYear)}>}aggr(sum($<Ano={$(vcurrentYear)}>}valor),idProdutoReservadoValor,Ano))

Not applicable
Author

Sorry, but due to confidentiality issues, I cannot provide sample data.

Not applicable
Author

Just tested... It returns full data results, not just the selected year. I think that it´s ignoring set analysis and even the selections made!

Clever_Anjos
Employee
Employee

Do you have alternate states into your app?

This expression must respect your selections because of $.

Very weird

Not applicable
Author

I do have Alternate States in the Document, but these Straight Table and the sheet has no active Alternate State. Furthermore, I created specific variables to test these expressions, because it wasn´t me that developed the app, and I wasn´t aware of the full implications of what was already developed.

If I´m not being clear with my text, ask to explain better, please. English is not my native language.

Thanks,

BS.

Clever_Anjos
Employee
Employee

You can scramble your data, will make our life easier Preparing examples for Upload - Reduction and Data Scrambling

Not applicable
Author

Here it is the reduced Qvw, as suggested by Clever Anjos.

The data that is returning as it is, it´s confirmed to be correct. So, any changes to expressions must return same values.

Thanks,

BS.

PSL_Operacional_1.qvw

Clever_Anjos
Employee
Employee

I didn´t understand very well your datamodel.

Check if this expression returns what you need for last year

=sum({$<Ano={$(vAnoAntSeleccionado)}>}Aggr(sum({$<Ano={$(vAnoAntSeleccionado)}>}Aggr(only({$<Ano={$(vAnoAntSeleccionado)}>}valor), idProdutoReservadoValor,Ano)), [Nome Social]))

View solution in original post