Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get previous n number of periods into dimention based on period selection?

Hi All,

can any one please guide me on the below scenario,

I have n no of periods per a year, if I select any one of the period among them, I need to show the 13 periods data prior to the selected period in the bar chart, how can I achieve it. Please help me on this.

Ex:   if I have  14  periods per a year

like 1,2,3,4,5,6,7,8,9,10,11,12,13,14

if I select a period 10  my bar chart has to show 

9,8,7,6,5,4,3,2,1,14,13,12,11

Here  9,87,6,5,4,3,2,1 belongs to the year 2015

14,13,12,11  belongs to the year 2014.

Regards

John

1 Solution

Accepted Solutions
Not applicable
Author

Thanks, Jacek Harazin.

I have the solution for it in my case I need to use like


LOAD Date,
     Period,
     Sales,
     Year(AddMonths(Date,-4)) as Year,
     Year(AddMonths(Date,-4))&'-'&Num(Period,00) as YearPeriod,
     AutoNumber( Year(AddMonths(Date,-4))&'-'&Num(Period,00)) as NrYearPeriod

Regards

John

View solution in original post

8 Replies
PrashantSangle

Hi,

Just add Period as your dimension but

in expression you have to write below condition

like

Sum({<period={"<=$(=max(period))>=$(=(max(period)-13))"}>}Sales)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

Thanks Max Dreamer,

can you please guide me on this also

how my dimension values will change according to my selection for this scenario

means if I select 10

my dimension  has to show 9,8,7,6,5,4,3,2,1,14,13,12,11

PrashantSangle

Hi,

Can you provide some sample data so that it will be easy to explain

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Jacek
Creator
Creator

Hi

Let`s try this scenario:

1) in load script make column with autonumber Year & Period as NrYearPeriod

2) in bar expression:

sum({1<NrYearPeriod={">$(=NrYearPeriod-15) <$(=NrYearPeriod) "}> }Sales)

I attached example with Your data

Regards

Jacek

Not applicable
Author

my selection field contains  only period values like 1 ,2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14.

it is not concatenate with year.

Jacek
Creator
Creator

In this case, how do you know which period belongs to which year?

You can use in my example filter with only period but it is necessary to select also year.

Not applicable
Author

Thanks, Jacek Harazin

I have gone through The file you have provided to me , there if I select particular Yearperiod value it is not going back to previous year it is giving same year values or it is missing some periods.

Not applicable
Author

Thanks, Jacek Harazin.

I have the solution for it in my case I need to use like


LOAD Date,
     Period,
     Sales,
     Year(AddMonths(Date,-4)) as Year,
     Year(AddMonths(Date,-4))&'-'&Num(Period,00) as YearPeriod,
     AutoNumber( Year(AddMonths(Date,-4))&'-'&Num(Period,00)) as NrYearPeriod

Regards

John