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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Splitting Targets

HI All

I Have a targets table and I want to split the Week target equally between each date

   Actual Table 

BranchWeek TargetStartDateEndDate
1015510.0003/09/201507/09/2015
1022270.0003/09/201507/09/2015
103650.0003/09/201507/09/2015
1041945.0003/09/201507/09/2015
1051620.0003/09/201507/09/2015
1062595.0003/09/201507/09/2015
1071135.0003/09/201507/09/2015

Expected table    

BranchDaily Target    DateStartDateEndDate
1011102.0003/09/201503/09/201507/09/2015
1011102.0004/09/201503/09/201507/09/2015
1011102.0005/09/201503/09/201507/09/2015
1011102.0006/09/201503/09/201507/09/2015
1011102.0007/09/201503/09/201507/09/2015

.102

103

Please Suggest how to do this

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

So, this can solve your needs

t:

LOAD Branch,

     [Week Target],

     StartDate,

     EndDate

FROM [https://community.qlik.com/thread/190466]

(html, codepage is 1252, embedded labels, table is @1);

t2:

load

  Branch,

  [Week Target],

  Date(StartDate + IterNo() - 1) as Date,

  [Week Target]/(EndDate-StartDate+1) as [Date Target],

  StartDate,

    EndDate

Resident t

While  StartDate + IterNo() - 1 <=  EndDate;

drop Table t;

View solution in original post

8 Replies
Anonymous
Not applicable
Author

Is it going to be fixed i.e 5 times for each?

Clever_Anjos
Employee
Employee

t:

LOAD Branch,

     [Week Target],

     StartDate,

     EndDate

FROM [https://community.qlik.com/thread/190466]

(html, codepage is 1252, embedded labels, table is @1);

load

  Branch,

  [Week Target],

  Date(StartDate + IterNo() - 1) as Date,

  [Week Target]/5 as [Date Target],

  StartDate,

     EndDate

Resident t

While  IterNo() <=  5;

drop Table t;

Final result

Capturar.PNG

Not applicable
Author

HI Balraj

it has to pick up the number of days between star Date and End Date

Clever_Anjos
Employee
Employee

Does your week´s number of days change?

andrespa
Specialist
Specialist

Hi John,  I'm afraid it's not possible to put conditions with join statements. But you can do something like this:

TARGETS:

LOAD Branch,

    [Week Target],

    StartDate,

    EndDate

FROM

(biff, embedded labels, table is Target$);

LEFT JOIN(TARGETS)

SALES:

LOAD Branch,

    Sales,

    Date

FROM

(biff, embedded labels, table is Sheet1$);

NoConcatenate

FINAL_TABLE:

LOAD * RESIDENT TARGETS

WHERE Date>StartDate AND Date<EndDate;

DROP TABLE FINAL_TABLE;

If I understand your requirement right, this should be one solution. Hope it helps.

Best regards,

Andrés

Not applicable
Author

HI Clever Anjos

the number of days between start Date and End Date varies

Most of them have  5 days

but some have only 4

In that case of 5 your script works correctly

but the day targets differs when t is 4 days 

Clever_Anjos
Employee
Employee

So, this can solve your needs

t:

LOAD Branch,

     [Week Target],

     StartDate,

     EndDate

FROM [https://community.qlik.com/thread/190466]

(html, codepage is 1252, embedded labels, table is @1);

t2:

load

  Branch,

  [Week Target],

  Date(StartDate + IterNo() - 1) as Date,

  [Week Target]/(EndDate-StartDate+1) as [Date Target],

  StartDate,

    EndDate

Resident t

While  StartDate + IterNo() - 1 <=  EndDate;

drop Table t;

Not applicable
Author

HI Clever Anjos

Thanks for your help