Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I have two input tables, Table1 and Table2 and I can link them based on common KEY.
Table1
KEY |
STATEID |
LAYERID |
Table2
KEY |
PERIOD |
VALUE1 |
VALUE2 |
VALUE3 |
Table1 fields with data:
STATEID | LAYERID |
STATE1 | CA |
STATE2 | TX |
STATE3 | FL |
Table 2 fields with data:
PERIOD | VALUE1 | VALUE2 | VALUE3 |
10011 | 101 | 201 | 301 |
10012 | 102 | 202 | 302 |
10013 | 103 | 203 | 303 |
How can we achieve final Output as below where the column header is the actual values from LayerID field instead of StateID values, which is dynamic and not hard coded ?
Appreciated any ideas....
Desired output
PERIOD | CA | TX | FL |
10011 | 101 | 201 | 301 |
10012 | 102 | 202 | 302 |
10013 | 103 | 203 | 303 |
Current output
PERIOD | STATE1 | STATE2 | STATE3 |
10011 | 101 | 201 | 301 |
10012 | 102 | 202 | 302 |
10013 | 103 | 203 | 303 |
I was able to get the desired output using agg() function
Could you include a sample of load script like this one?
table1:
load * inline [
KEY, STATEID, LAYERID
1, STATE1, CA
2, STATE2, TX
3, STATE3, FL
]
;
table2:
load * inline [
KEY, PERIOD, VALUE1, VALUE2, VALUE3
1, 10011, 101, 201, 301
2, 10012, 102, 202, 302
3, 10013, 103, 203, 303
]
;
I used this to try to test solutions, but it doesn't produce a chart like your current output, so I don't think I did it correctly. What are the KEY values in the two tables? How do they join the data?