Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Community,
I have two fields having values as below
id | Val |
1 | 39 |
2 | 193 |
3 | 64 |
4 | 123 |
5 | 96 |
6 | 116 |
7 | 126 |
8 | 72 |
9 | 118 |
10 | 99 |
11 | 117 |
12 | 148 |
13 | 146 |
14 | 88 |
and i want the output like this:
id | Val | val-1 | val-2 | val-3 | val-4 |
1 | 39 | 193 | 64 | 123 | 96 |
2 | 193 | 64 | 123 | 96 | 116 |
3 | 64 | 123 | 96 | 116 | 126 |
4 | 123 | 96 | 116 | 126 | 72 |
5 | 96 | 116 | 126 | 72 | 118 |
6 | 116 | 126 | 72 | 118 | 99 |
7 | 126 | 72 | 118 | 99 | 117 |
8 | 72 | 118 | 99 | 117 | 148 |
9 | 118 | 99 | 117 | 148 | 146 |
10 | 99 | 117 | 148 | 146 | 88 |
11 | 117 | 148 | 146 | 88 | 0 |
12 | 148 | 146 | 88 | 0 | 0 |
13 | 146 | 88 | 0 | 0 | 0 |
14 | 88 | 0 | 0 | 0 | 0 |
How can i do this from backend pls suggest me.
Thanks
Try this:
Table:
LOAD * Inline [
id, Val
1, 39
2, 193
3, 64
4, 123
5, 96
6, 116
7, 126
8, 72
9, 118
10, 99
11, 117
12, 148
13, 146
14, 88
];
NewTable:
LOAD id,
Val,
Alt(Peek('Val', -1), 0) as Val1,
Alt(Peek('Val', -2), 0) as Val2,
Alt(Peek('Val', -3), 0) as Val3,
Alt(Peek('Val', -4), 0) as Val4
Resident Table
Order By id desc;
DROP Table Table;
Output in a table box object:
Try this:
Table:
LOAD * Inline [
id, Val
1, 39
2, 193
3, 64
4, 123
5, 96
6, 116
7, 126
8, 72
9, 118
10, 99
11, 117
12, 148
13, 146
14, 88
];
NewTable:
LOAD id,
Val,
Alt(Peek('Val', -1), 0) as Val1,
Alt(Peek('Val', -2), 0) as Val2,
Alt(Peek('Val', -3), 0) as Val3,
Alt(Peek('Val', -4), 0) as Val4
Resident Table
Order By id desc;
DROP Table Table;
Output in a table box object:
Hi Sunny
Thanks its working perfect
Can you also tell me how can i do this in front end in straight table With only "id" and "val" fields.
Hi,
Try like this
TableName:
LOAD id,
Val,
Alt(Peek('Val', -1), 0) AS Val1,
Alt(Peek('Val', -2), 0) AS Val2,
Alt(Peek('Val', -3), 0) AS Val3,
Alt(Peek('Val', -4), 0) AS Val4
FROM DataSource
ORDER BY id des;
Regards,
Jagan.
Hi,
You can try in front end by Below() in straight table.
Regards,
Jagan.
Have a look at this.
This is a straight table:
Dimension: id
Expressions:
1) Val
2) Alt(Below(Val), 0)
3) Alt(Below(Val, 2), 0)
4) Alt(Below(Val, 3), 0)
5) Alt(Below(Val, 4), 0)
Please find attached file for solution in front end.
Regards,
Jagan.
Thanks everyone i got it
PFA