Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
kolov007
Contributor III
Contributor III

Add date field for each record that is between two dates (start and finish)

Help me, please, is there a possibility into QlikView to solve the following problem:

There is database, which includes three fields: Shop, Product, Start date, Date of end.


KeyShopProductStart dateDate of end
1Shop 1Product 101/08/2015

04/08/2015

2Shop 2Product 110/08/201512/08/2015
3Shop 3Product 202/08/201504/08/2015


Is it possible in QlikView, for each key field (which corresponds to the action of a particular product in a particular shop) to assign all of the dates during which lasted this action. For example, if you select into QlikView date - 03.08.2015, in the list box of active shop would be two records - the shop 1 and 3.


KeyDate
101/08/2015
102/08/2015
103/08/2015
104/08/2015

2

10/08/2015
211/08/2015
212/08/2015
302/08/2015
303/08/2015
304/08/2015


1 Solution

Accepted Solutions
MarcoWedel

one solution could be:

QlikCommunity_Thread_180208_Pic3.JPG

QlikCommunity_Thread_180208_Pic1.JPG

QlikCommunity_Thread_180208_Pic2.JPG

table1:

LOAD * FROM [https://community.qlik.com/thread/180208] (html, codepage is 1252, embedded labels, table is @1);

tabCalendar:

LOAD *,

     Day(Date) as Day,

     WeekDay(Date) as WeekDay,

     Week(Date) as Week,

     WeekName(Date) as WeekName,

     WeekYear(Date) as WeekYear,

     Month(Date) as Month,

     MonthName(Date) as MonthName,

     Dual('Q'&Ceil(Month(Date)/3),Ceil(Month(Date)/3)) as Quarter,

     QuarterName(Date) as QuarterName,

     Year(Date) as Year;

LOAD Date(MinDate+IterNo()-1) as Date

While MinDate+IterNo()-1 <= MaxDate;

LOAD Min([Start date]) as MinDate,

     Max([Date of end]) as MaxDate

Resident table1;

tabLink:

IntervalMatch(Date)

LOAD [Start date],

     [Date of end]

Resident table1;

hope this helps

regards

Marco

View solution in original post

5 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Yes, check out the syntax of the WHILE clause. Your syntax will look similar to the following:

LOAD

   Key1,

   Key2,

   Key3,

   ...

   Start,

   End,

   Date(Start + IterNo() - 1) as Date

Resident

   MyTable

WHILE

     Date(Start + IterNo() - 1) <= End

;

cheers,

Oleg Troyansky

QlikView Your Business: An expert guide to Business Discovery with QlikView and Qlik Sense

qlikviewwizard
Master II
Master II

Hi kolov007,

Please check the attached file. Is this solution you are looking for?

Hi troyansky

I did not understand your solution. Could you provide full script for this.

Thank you.

qlikviewwizard
Master II
Master II

Attachment.

MarcoWedel

Search for master calendar and the intervalmatch prefix.

Regards

Marco

MarcoWedel

one solution could be:

QlikCommunity_Thread_180208_Pic3.JPG

QlikCommunity_Thread_180208_Pic1.JPG

QlikCommunity_Thread_180208_Pic2.JPG

table1:

LOAD * FROM [https://community.qlik.com/thread/180208] (html, codepage is 1252, embedded labels, table is @1);

tabCalendar:

LOAD *,

     Day(Date) as Day,

     WeekDay(Date) as WeekDay,

     Week(Date) as Week,

     WeekName(Date) as WeekName,

     WeekYear(Date) as WeekYear,

     Month(Date) as Month,

     MonthName(Date) as MonthName,

     Dual('Q'&Ceil(Month(Date)/3),Ceil(Month(Date)/3)) as Quarter,

     QuarterName(Date) as QuarterName,

     Year(Date) as Year;

LOAD Date(MinDate+IterNo()-1) as Date

While MinDate+IterNo()-1 <= MaxDate;

LOAD Min([Start date]) as MinDate,

     Max([Date of end]) as MaxDate

Resident table1;

tabLink:

IntervalMatch(Date)

LOAD [Start date],

     [Date of end]

Resident table1;

hope this helps

regards

Marco