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: 
karelibarcar
Contributor III
Contributor III

What's wrong?

Hello,

Someone can tell me where is the mistake in this:

Imagen1.png

I'm trying to get the value of the last month but it seems as my variable doesn't function

1 Solution

Accepted Solutions
richard_hanipc
Partner - Contributor
Partner - Contributor

It's working but not how you intended

-----

In your image I observed that you have 2017 selected for year(año) and January(ene) selected for month(Mes)?

the variable vMesAnterior returns 12

if you have 2017 for year selected and the variable returns 12 then I assume there isn't any data for year 2017 and month 12? so the expression is correct in returning 0

-----

I recommend creating an expression where if you want previous month data it would be wiser to have an unique id for each month and year so you can have a rolling calendar


in the script in your calendar table I recommend creating a MonthID field like so or something like this

Year(max(DATEfield)-1) *12  + num(month(max(DATEfield))) as MESID

reload and in your expression input the following expression with the new field MESID

Sum({$<MESID = {“>=$(=Max(MESID) – 1)<=$(=Max(MESID))”}, Año = , Mes = >} Valor_Cuenta)

this expression gives you a range summation

View solution in original post

8 Replies
sunny_talwar

Try adding an equal sign

Num_Mes = {$(=vMesAnterior)}

karelibarcar
Contributor III
Contributor III
Author

Thanks for answering but it has not worked

sunny_talwar

I think you might have to ignore selection in Mes also

sunny_talwar

Num_Mes = {$(=vMesAnterior)}, Mes

karelibarcar
Contributor III
Contributor III
Author

Bad news, it does not work either

sunny_talwar

Would you be able to share a sample?

richard_hanipc
Partner - Contributor
Partner - Contributor

It's working but not how you intended

-----

In your image I observed that you have 2017 selected for year(año) and January(ene) selected for month(Mes)?

the variable vMesAnterior returns 12

if you have 2017 for year selected and the variable returns 12 then I assume there isn't any data for year 2017 and month 12? so the expression is correct in returning 0

-----

I recommend creating an expression where if you want previous month data it would be wiser to have an unique id for each month and year so you can have a rolling calendar


in the script in your calendar table I recommend creating a MonthID field like so or something like this

Year(max(DATEfield)-1) *12  + num(month(max(DATEfield))) as MESID

reload and in your expression input the following expression with the new field MESID

Sum({$<MESID = {“>=$(=Max(MESID) – 1)<=$(=Max(MESID))”}, Año = , Mes = >} Valor_Cuenta)

this expression gives you a range summation

karelibarcar
Contributor III
Contributor III
Author

Thank you so much! It works fine!