Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
anwarbham
Contributor III
Contributor III

Previous Period expression Qlik Sense

Hi Im looking for an easier way to write the below expression to get the previous period 

we have 3 periods in a year I would like to get the previous period. if today is the period actual.

for me the below works.

= if( (Month(Today())-1) >= Month([Cycle Start Date]) and (Month(Today())-1) <= Month([Cycle End Date]) , 0, if (Year(today()) = Year([Cycle Start Date]) , 1,0)) 

i get the result below

previous CycleDate([Cycle Start Date])Date([Cycle End Date])Cycle
001.05.201931.08.201901/05/2019 - 31/08/2019
001.09.201931.12.201901/09/2019 - 31/12/2019
001.05.202031.08.202001/05/2020 - 31/08/2020
101.01.202030.04.202001/01/2020 - 30/04/2020
001.09.201831.12.201801/09/2018 - 31/12/2018
001.01.201830.04.201801/01/2018 - 30/04/2018
001.01.201930.04.201901/01/2019 - 30/04/2019
001.05.201731.08.201701/05/2017 - 31/08/2017
001.01.201730.04.201701/01/2017 - 30/04/2017
001.09.201731.12.201701/09/2017 - 31/12/2017

 

which is correct 

im only going to want to know the previous period one month after actual period has started.

But is there a better way to do this i was thinking of using Previous statement in the Script , but that will only tell me what the previous period was on the same row as the actual period, i need a flag to tell me the previous period.

 

Thanks

 

 

Labels (3)
0 Replies