Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Comparison with the previous year


I want to compare in a simple table the amount for the year I have selected with the preceding year.

I am making a mistake in the definition of the expression for the preeding year because the table does not display any data.

This is what I´m doing:

FOR THE YEAR SELECTED: It works

  • LABEL:

                $(=Max(MbrName_Anio))

  • DEFINITION:

                   ({$ <[MbrName_Anio]= {$(=Max(MbrName_Anio))} > } [Importe real]

FOR THE PRECEDING YEAR: The Label works but the Expression don´t

  • LABEL:It works

                $(=Max(MbrName_Anio)-1) 

  • DEFINITION: It doesn´t work

                 ({$ <[MbrName_Anio]= {$(=Max(MbrName_Anio)-1)} > } [Importe real])  

What am I doing wrong?

Thanks in advance for your answers!!

6 Replies
Clever_Anjos
Employee
Employee

Basically you´re doing right.

Is it possible to post a app?

stabben23
Partner - Master
Partner - Master

Hi,

move your -1 inside brackets, like: {$(=max(MbrName_Anio -1))}

stabben23
Partner - Master
Partner - Master

Maybe MbrName_Anio is non numeric?

trey_bayne
Partner - Creator
Partner - Creator

The Label is not paying attention to your Selection Set. It's just using the dollar sign expansion. That's why it works.

In your definition, you are defining the Selection Set as the current set using $, meaning that it's possible the Selection Set ( List Boxes highlighted green) references the current MbrName_Anio. If that's the case, you are eliminating MbrName_Anio-1 by selecting MbrName_Anio.

You can get around this by using   ({1 <[MbrName_Anio]= {$(=Max(MbrName_Anio))} > } [Importe real])  or using an additional modifier to tell the Set Analysis Set to ignore a selection you've made in another QlikView Object ( List Box maybe?).

SunilChauhan
Champion
Champion

Hi,

ru using any set aggr function like sum,count avg ...beacause set doesn't work without them

sum  ({$ <[MbrName_Anio]= {"$(=Max(MbrName_Anio)-1)"} > } [Importe real])  .

if you attached sample file then that would be great to help you

Sunil Chauhan
PrashantSangle

Hi,

Try several alternatives.

Like

1. Write $(=Max(MbrName_Anio)-1) in single quote ' '

Like

({<[MbrName_Anio]= {'$(=Max(MbrName_Anio)-1)'}>} [Importe real]

2.

store value of $(=Max(MbrName_Anio)-1) expression in variable

Like create variable varPreviousYear

and value should be =Max(MbrName_Anio)-1


Then use that variable in your set analysis

Like

({<[MbrName_Anio]= {"=varPreviousYear"}>} [Importe real]


Regards,


Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂