Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with creating transactions from values

Dear everyone,

First post here.

I need help with a transform.

I have this:

                                                  

IDVALTIMEVALUE
12013-12-010,00
12014-01-011,00
12015-01-011,00
12016-01-010,80
12017-01-010,60


I want this:

                                                          

IDVALTIMESTARTDATEENDDATEVALUE
12013-12-012013-12-012013-12-310,00
12014-01-012014-01-012014-12-311,00
12015-01-012015-01-012015-12-311,00
12016-01-012016-01-012016-12-310,80
12017-01-012017-01-01 0,60

In my case (electricity retailer) the ID is a delivery site and the values are some order information. I want to create a start- and enddate from the first table so I can run an interval-match and see what order is valid on a specific date. The enddate is the next rows startdate -1.

Please help!

Jakob

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

Temp:

Load ID,Date#(VALTIME,'YYYY-MM-DD') As VALTIME,VALUE Inline [

ID,VALTIME,VALUE

1,2013-12-01,0.00

1,2014-01-01,1.00

1,2015-01-01,1.00

1,2016-01-01,0.80

1,2017-01-01,0.60 ];

Final:

Load *,VALTIME As STARTDATE,If(ID = Previous(ID), Date(Previous(VALTIME)-1,'YYYY-MM-DD')) As ENDDATE Resident Temp Order by ID,VALTIME desc;

Drop Table Temp;

View solution in original post

2 Replies
anbu1984
Master III
Master III

Temp:

Load ID,Date#(VALTIME,'YYYY-MM-DD') As VALTIME,VALUE Inline [

ID,VALTIME,VALUE

1,2013-12-01,0.00

1,2014-01-01,1.00

1,2015-01-01,1.00

1,2016-01-01,0.80

1,2017-01-01,0.60 ];

Final:

Load *,VALTIME As STARTDATE,If(ID = Previous(ID), Date(Previous(VALTIME)-1,'YYYY-MM-DD')) As ENDDATE Resident Temp Order by ID,VALTIME desc;

Drop Table Temp;

Not applicable
Author

Beautiful. Thank you!