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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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.

Labels (1)
1 Solution

Accepted Solutions
Clever_Anjos
Support
Support

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
Support
Support

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
Support
Support

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
Support
Support

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
Support
Support

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]))