Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
qliknexus_kgcru
Partner - Contributor III
Partner - Contributor III

display the previous 6 months and the next 5 months based on a selected month

Hi All,

I want to display the previous 6 months and the next 5 months based on a selected month. Here is my data:

YearMonthQuarterSalesCATEGORY
2017January413000A
2017February414000B
2017March415000A
2017April116000B
2017May117000A
2017June118000B
2017July219000A
2017August220000B
2017September221000A
2017October322000B
2017November323000A
2017December324000B
2018January425000A
2018February426000B
2018March427000A
2018April128000B
2018May129000A
2018June130000B
2018July231000A
2018August232000B
2018September233000A
2018October334000B
2018November335000A
2018December336000B

e.g. I have selected YEAR=2018 and MONTH=MARCH, it should show me the selected month, the previous 6 months and the next 5 months like so:

YearMonthQuarterSalesCATEGORY
2017September221000A
2017October322000B
2017November323000A
2017December324000B
2018January425000A
2018February426000B
2018March427000A
2018April128000B
2018May129000A
2018June130000B
2018July231000A
2018August232000B

Thanks for any help.

6 Replies
fvelascog72
Partner - Specialist
Partner - Specialist

Hi,

Try creating a field Period with YearMonth and select the range in set analysis.

Saludos.

qliknexus_kgcru
Partner - Contributor III
Partner - Contributor III
Author

Hi,

I already created a YearMonth by using this code:

     Year&num(Month(Date#(Month,'MMM')),'00') as YearMonth

Now, i'm having troubles on how to add a months to it.

olivierrobin
Specialist III
Specialist III

hello

why don't you add day 01 to your YearMonth date, so you can use qlik date functions ?

qliknexus_kgcru
Partner - Contributor III
Partner - Contributor III
Author

The result of my YearMonth is e.g. 201803, how do i add the day? thanks!

olivierrobin
Specialist III
Specialist III

maybe

YearMonth*100+1