Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all
I have data given in such way
USD | 12-Jan-18 | 60 |
INR | 25-Jan-18 | 15 |
USD | 14-May-18 | 62 |
INR | 14-Jul-18 | 16 |
USD | 01-Oct-18 | 61 |
INR | 28-Feb-19 | 18 |
and i want to create a table like this
USD | 12-Jan-18 | 13-May-18 | 60 |
INR | 25-Jan-18 | 13-Jul-18 | 15 |
USD | 14-May-18 | 30-Sept-18 | 62 |
INR | 14-Jul-18 | 27-Feb-19 | 16 |
USD | 01-Oct-18 | (PresentDay) | 61 |
INR | 28-Feb-19 | (PresentDay) | 18 |
Can anyone help me achieve this.
Try below logic,
Base:
Load * inline [
Currency,Date,Value
USD,12-Jan-2018,60
INR,25-Jan-2018,15
USD,14-May-2018,62
INR,14-Jul-2018,16
USD,01-Oct-2018,61
INR,28-Feb-2019,18
];
NoConcatenate
Temp:
Load
Currency,
Date(Date#(Date,'DD-MMMM-YYYY'),'DD/MM/YYYY') as StartDate,
Value
Resident Base;
Drop Table Base;
Final:
Load
Currency,
StartDate,
if(Currency= Previous(Currency),Date(Previous(StartDate)-1),Today()) as EndDate,
Value
Resident Temp Order by Currency,StartDate desc;
Drop Table Temp;
What is the logic behind?