Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for Data Integration and Data Analytics gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor

Problem with Set Analysis

Hola,
Estoy teniendo un problema con un set analisis.
Quiero calcular el mes anterior de un campo. Mi fecha es formato YYYY-MM y el campo es "Periodo". 

sum( {$<Periodo={"<=$(=date(Periodo-1))>"}>}  CampoASumar)

Alguien me puede corregir esto? 

Gracias.

 

4 Replies
Highlighted
Specialist II
Specialist II

Re: Problem with Set Analysis

create variable

Periodo_new =

=Makedate(Year(Date#(Periodo,'YYYY-MM')),Month(Date#(Periodo,'YYYY-MM')),1)

Capture.PNG

then the New Set analysis :

sum( {$<Periodo_new={"<=$(=Addmonths(Periodo_new,-1))>"}>} CampoASumar)

 

Regards,
Taoufiq ZARRA
Highlighted
Contributor
Contributor

Re: Problem with Set Analysis

Hi, thanks for the quick answer. 
I tried what you said, but its giving me back the value of the current month, not the value of the month before. 

Highlighted
Specialist II
Specialist II

Re: Problem with Set Analysis

ah ok

may be

 

=Sum({<Periodo_new= {"$(=Addmonths(Periodo_new,-1))"}>} CampoASumar)

Regards,
Taoufiq ZARRA
Highlighted

Re: Problem with Set Analysis

may be this

 

sum( {$<Periodo={"<=$(=date(addmonths(max(Periodo),-1),'YYYY-MM'))>"}>}  CampoASumar)