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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
ecabanas
Creator II
Creator II

Create a table from another

Hi all,

I'm in a trouble. I have a table like this:

   

ItemIdFromToTarifa
1035785601/02/201629/02/20160,88
1035785601/03/201631/12/20160,52

I would like to create a table For every month an ID ItemId+Date like this:

  

DateIDPrice
28/02/201610357856-424280,88
31/03/201610357856-424600,52
30/04/201610357856-424900,52
31/05/201610357856-425210,52
30/06/201610357856-425510,52
31/07/201610357856-425820,52
31/08/201610357856-426130,52
30/09/201610357856-426430,52

Many many thank's again

Eduard

1 Solution

Accepted Solutions
sunny_talwar

May be like this:

Table:

LOAD *,

  Date(Floor(MonthEnd(From, IterNo() - 1))) as Date,

  ItemId & '-' & Floor(MonthEnd(From, IterNo() - 1)) as ID

While Floor(MonthEnd(From, IterNo() - 1)) <= To;

LOAD * INLINE [

    ItemId, From, To, Tarifa

    10357856, 01/02/2016, 29/02/2016, "0,88"

    10357856, 01/03/2016, 31/12/2016, "0,52"

];


Capture.PNG

View solution in original post

3 Replies
sunny_talwar

May be like this:

Table:

LOAD *,

  Date(Floor(MonthEnd(From, IterNo() - 1))) as Date,

  ItemId & '-' & Floor(MonthEnd(From, IterNo() - 1)) as ID

While Floor(MonthEnd(From, IterNo() - 1)) <= To;

LOAD * INLINE [

    ItemId, From, To, Tarifa

    10357856, 01/02/2016, 29/02/2016, "0,88"

    10357856, 01/03/2016, 31/12/2016, "0,52"

];


Capture.PNG

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

NewTable:

LOAD

     Date(MonthStart(From,IterNo())-1) as Date,

     ItemId & '-' & num(MonthStart(From,IterNo())-1) as ID,

     Price

FROM

     ...source_table

WHILE

     MonthStart(From,IterNo())-1 < To

     ;

If From and To are strings instead of date then first use the date# function on them to turn the strings into dates:

date#(From, 'DD/MM/YYYY')

date#(To, 'DD/MM/YYYY')


talk is cheap, supply exceeds demand
ecabanas
Creator II
Creator II
Author

Great Sunny as always!!!

Thank you