Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I need to fill the data, only when it's between the same data.
Key | Date | Field 2 |
---|---|---|
1234 | 01.01.2018 | |
1234 | 02.01.2018 | Data 2 |
1234 | 03.01.2018 | |
1234 | 04.01.2018 | |
1234 | 05.01.2018 | Data 2 |
1234 | 06.01.2018 |
Final Table should be this, in order by Key, Date
Key | Date | Field 2 |
---|---|---|
1234 | 01.01.2018 | |
1234 | 02.01.2018 | Data 2 |
1234 | 03.01.2018 | Data 2 |
1234 | 04.01.2018 | Data 2 |
1234 | 05.01.2018 | Data 2 |
1234 | 06.01.2018 |
With my script everything is filled with the last value.
Can someone help me?
Thanks
I works, but not always.
I forgot something, 1 Key can have more different data:
Key | Date | Field 2 |
---|---|---|
1234 | 01.01.2018 | |
1234 | 02.01.2018 | Data 1 |
1234 | 03.01.2018 | |
1234 | 04.01.2018 | |
1234 | 05.01.2018 | Data 1 |
1234 | 06.01.2018 | |
1234 | 07.01.2018 | Data 2 |
1234 | 08.01.2018 | |
1234 | 09.01.2018 | Data 2 |
1234 | 10.01.2018 |
I would need the table to be like this:
Key | Date | Field 2 |
---|---|---|
1234 | 01.01.2018 | |
1234 | 02.01.2018 | Data 1 |
1234 | 03.01.2018 | Data 1 |
1234 | 04.01.2018 | Data 1 |
1234 | 05.01.2018 | Data 1 |
1234 | 06.01.2018 | |
1234 | 07.01.2018 | Data 2 |
1234 | 08.01.2018 | Data 2 |
1234 | 09.01.2018 | Data 2 |
1234 | 10.01.2018 |
Try this
Table:
LOAD * INLINE [
Key, Date, Field 2
1234, 01.01.2018,
1234, 02.01.2018, Data 1
1234, 03.01.2018,
1234, 04.01.2018,
1234, 05.01.2018, Data 1
1234, 06.01.2018,
1234, 07.01.2018, Data 2
1234, 08.01.2018,
1234, 09.01.2018, Data 2
1234, 10.01.2018
];
TempTable:
NoConcatenate
LOAD Key,
Date,
[Field 2],
If(Len(Trim([Field 2])) = 0, Peek('Field 2 New'), [Field 2]) as [Field 2 New]
Resident Table
Order By Key, Date;
DROP Table Table;
Left Join (TempTable)
LOAD Key,
[Field 2] as [Field 2 New],
Max(Date) as MaxDate,
Min(Date) as MinDate
Resident TempTable
Where Len(Trim([Field 2])) > 0
Group By Key, [Field 2];
FinalTable:
LOAD Key,
Date,
If(Date >= MinDate and Date <= MaxDate, [Field 2 New]) as [Field 2]
Resident TempTable
Order By Key, Date;
DROP Table TempTable;