Qlik Community

Ask a Question

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
Do More with Qlik - for Beginners and Beyond, Topic: Qlik Replicate on January 21, 2PM EST. REGISTER NOW
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
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
MVP
MVP

If possible please upload your sample file or apps.

Employee
Employee

I think your expression should be:

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

Not applicable

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

Not applicable

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!

Employee
Employee

Do you have alternate states into your app?

This expression must respect your selections because of $.

Very weird

Not applicable

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.

Employee
Employee

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

Not applicable

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

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