
Contributor III
2020-06-03
05:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 Cycle | Date([Cycle Start Date]) | Date([Cycle End Date]) | Cycle |
0 | 01.05.2019 | 31.08.2019 | 01/05/2019 - 31/08/2019 |
0 | 01.09.2019 | 31.12.2019 | 01/09/2019 - 31/12/2019 |
0 | 01.05.2020 | 31.08.2020 | 01/05/2020 - 31/08/2020 |
1 | 01.01.2020 | 30.04.2020 | 01/01/2020 - 30/04/2020 |
0 | 01.09.2018 | 31.12.2018 | 01/09/2018 - 31/12/2018 |
0 | 01.01.2018 | 30.04.2018 | 01/01/2018 - 30/04/2018 |
0 | 01.01.2019 | 30.04.2019 | 01/01/2019 - 30/04/2019 |
0 | 01.05.2017 | 31.08.2017 | 01/05/2017 - 31/08/2017 |
0 | 01.01.2017 | 30.04.2017 | 01/01/2017 - 30/04/2017 |
0 | 01.09.2017 | 31.12.2017 | 01/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
- Tags:
- expression
653 Views
0 Replies
