Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Looping between months

Hi,

I have the sales of 10 stores saved in a table for every month; in other words, in table Sales1601 there are the sales that the 10 stores made in January '16, in table Sales1602 there are the sales that the 10 stores made in February '16, in table Sales1501 there are the sales that the 10 stores made in January '15 exc.

I'd like to have a script that's able to read the current month(Ex: March) and load all the data referring to the previous months (February and January), for the current year and also for the previous year.

Someone knows how to do it?

Thanks.

5 Replies
amayuresh
Contributor III

Re: Looping between months

Can use expression as

=sum({<Date={'>$(=MonthStart(Addmonths(Max(Date),-2)))'}>}Sales)

manojkulkarni
Valued Contributor II

Re: Looping between months

Use Today() function to get current month year in required format. eg:

Date(Today(),'YYMM') which will return 1603

use loop to get all the numbers associated with tables like 1501,1601,1602 etc which are lessthan current month year number & inner loop use these number to fetch data from specific tables.

Re: Looping between months

Can you explain what you're trying to do? Do you want to load source data into the qlikview document? Or have you already loaded the data in the qlikview document and are you asking about creating an expression for a chart?

Can you post a small qlikview document that demonstrates the problem?


talk is cheap, supply exceeds demand
Not applicable

Re: Looping between months

Hi Gysbert,

I want to load source data into the qlik document.

I don't know how to "write" the script in order to load all the months before the actual.

Re: Looping between months

Perhaps like this:

LOAD * FROM mysource WHERE Date < today();


talk is cheap, supply exceeds demand
Community Browser