Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
tyagishaila
Specialist
Specialist

add field in a table on script

Need Solution on script not on dashboard

ItemStartingDatePrice
A20-05-20153999
B15-02-20135000
B03-01-20144500
B23-01-20144999
C07-01-2012399
C08-02-2015199
D02-02-20134999
E12-12-20152499
E31-12-20151499

I have an above Item table, In which an item has different price on different date.

I need to show a range of dates Starting Date and Ending Date, to know between which dates an item has  what price?

for example

Item B sold on 5000/- since 15-02-2013 to 02-01-2014 (previous date of next price change date of that Item.

Basically I need an EndingDate field

ItemStarting DateEndingDatePrice
A20-05-2015Today Date3999
B15-02-201302-01-20145000
B03-01-201422-01-20144500
B23-01-201418-02-2016(Today Date)4999
C07-01-201207-02-2015399
C08-02-2015Today Date199
D02-02-2013TodayDate4999
E12-12-201530-12-20152499
E31-12-2015Today Date1499

Thanks

1 Solution

Accepted Solutions
MayilVahanan

Hi

Try like this

T:

LOAD Item, date(Date#(StartingDate, 'DD-MM-YYYY')) As StartingDate, Price INLINE [

    Item, StartingDate, Price

    A, 20-05-2015, 3999

    B, 15-02-2013, 5000

    B, 03-01-2014, 4500

    B, 23-01-2014, 4999

    C, 07-01-2012, 399

    C, 08-02-2015, 199

    D, 02-02-2013, 4999

    E, 12-12-2015, 2499

    E, 31-12-2015, 1499

];

Load *,  Date(If(Previous(Item) = Item , Previous(StartingDate) -1, Today())) As EndingDate Resident T Order by Item, StartingDate desc;

DROP Table T;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

4 Replies
marcus_sommer

You could do it with Peek() or Previous() ?

- Marcus

MayilVahanan

Hi

Try like this

T:

LOAD Item, date(Date#(StartingDate, 'DD-MM-YYYY')) As StartingDate, Price INLINE [

    Item, StartingDate, Price

    A, 20-05-2015, 3999

    B, 15-02-2013, 5000

    B, 03-01-2014, 4500

    B, 23-01-2014, 4999

    C, 07-01-2012, 399

    C, 08-02-2015, 199

    D, 02-02-2013, 4999

    E, 12-12-2015, 2499

    E, 31-12-2015, 1499

];

Load *,  Date(If(Previous(Item) = Item , Previous(StartingDate) -1, Today())) As EndingDate Resident T Order by Item, StartingDate desc;

DROP Table T;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
tyagishaila
Specialist
Specialist
Author

Superb, its working.

Thanks MAYIL

tyagishaila
Specialist
Specialist
Author

Thanks Marcus,

Your reply is really helpful for me.

cheers