Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
slondono
Partner - Creator II
Partner - Creator II

Get Max of a possible list selection

Hi everyone

I need to get the Max in a possible list.

Something like this:

Captura.PNG

I need to get that '46' and put in into my set analysis. In this case is 46 but there may be other cases in which is other number.

(In Orange the important)

I tried this : Sum({<max(Empleado.Semana= p(Empleado.Semana)) ,Empleado.fechaRetiro={">=01/01/$(vAñoActual)<=31/12/$(vAñoActual)"},Empleado.Año={$(vAñoActual)},Calendario.AnoNomina=>}1)

Tried this too: vMaxWeek = Max(Empleado.Semana) ....This get the '46' but when i put it into the set analysis it doesnt work

Sum({<Empleado.Semana={$(vMaxWeek)},Empleado.fechaRetiro={">=01/01/$(vAñoActual)<=31/12/$(vAñoActual)"},Empleado.Año={$(vAñoActual)},Calendario.AnoNomina=>}1)


Any idea?

1 Solution

Accepted Solutions
p_verkooijen
Partner - Specialist
Partner - Specialist

First of all, what is the expression used for vMaxWeek

  1. =MAX(Week)
  2. MAX(Week)

When the variable expression is 1 use Empleado.Semana={$(vMaxWeek)}

When the variable expression is 2 use Empleado.Semana={$(=$(vMaxWeek))}

This is because the first is already evaluated and is 46, the second contains only the logic and has to be evaluated.

Also if you don't set the label of a expression you can read the outcome of the statement. Very usefull if you use several variables and youre not sure if the syntax is correct.

Also like swuehl‌ states, please share what does work, and what you've tested.

View solution in original post

12 Replies
sunny_talwar

Try this:

Sum({<Empleado.Semana={$(=$(vMaxWeek))},Empleado.fechaRetiro={">=01/01/$(vAñoActual)<=31/12/$(vAñoActual)"},Empleado.Año={$(vAñoActual)},Calendario.AnoNomina=>}1)

slondono
Partner - Creator II
Partner - Creator II
Author

Not Working :s

sunny_talwar

What about this:

Sum({<Empleado.Semana={'$(=$(vMaxWeek))'},Empleado.fechaRetiro={">=01/01/$(vAñoActual)<=31/12/$(vAñoActual)"},Empleado.Año={$(vAñoActual)},Calendario.AnoNomina=>}1)

swuehl
MVP
MVP

What about

Sum({<Empleado.Semana={$(=Max(Empleado.Semana))},Empleado.fechaRetiro={">=01/01/$(vAñoActual)<=31/12/$(vAñoActual)"},Empleado.Año={$(vAñoActual)},Calendario.AnoNomina=>}1)

slondono
Partner - Creator II
Partner - Creator II
Author

Not working

slondono
Partner - Creator II
Partner - Creator II
Author

Not Working

swuehl
MVP
MVP

Not working is not very helpful...

Do you get a correct value when you input the 46 as constant:

Sum({<Empleado.Semana={46},Empleado.fechaRetiro={">=01/01/$(vAñoActual)<=31/12/$(vAñoActual)"},Empleado.Año={$(vAñoActual)},Calendario.AnoNomina=>}1)


I wonder if you really want to sum a constant 1 here. What do you get returned (e.g. when using

Sum({<Empleado.fechaRetiro={">=01/01/$(vAñoActual)<=31/12/$(vAñoActual)"},Empleado.Año={$(vAñoActual)},Calendario.AnoNomina=>} 1)

)?


Could you upload a small sample QVW and your requested result?

p_verkooijen
Partner - Specialist
Partner - Specialist

First of all, what is the expression used for vMaxWeek

  1. =MAX(Week)
  2. MAX(Week)

When the variable expression is 1 use Empleado.Semana={$(vMaxWeek)}

When the variable expression is 2 use Empleado.Semana={$(=$(vMaxWeek))}

This is because the first is already evaluated and is 46, the second contains only the logic and has to be evaluated.

Also if you don't set the label of a expression you can read the outcome of the statement. Very usefull if you use several variables and youre not sure if the syntax is correct.

Also like swuehl‌ states, please share what does work, and what you've tested.

slondono
Partner - Creator II
Partner - Creator II
Author

Hi, You're rigth, "not working" is not helpful.

Look, This is the result I should get.

Captura.PNG

The idea is to show the position of a person when it leaves the company. in this case a person had a position "EQ. ATENC.CLIENTES ..." from week 1 through week 44, then changed his position and went on to "dept. CANALAES FACE .." in week 45 and 46. This person left the company at week 46 (the last record). Then I need only the first record of the original image.

Here the link to the test.qwv: test.qvw