Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'd like to know please if there is a way to use the Value/Content of a field as field name in the AS of a LOAD statement.
Example:
In a Table 'Maschinen' there is (among many others) a field 'MaschID' like
'TP01_01_01'
'TP01_01_02'
...
'TP_02_01_01'
...
In al LOAD statement, I check the MaschID and collect data like this:
TempData:
load
foo1 as bar2,
foo2 as bar3
...
resident Maschinen
where left(MaschID, 4) = 'TP01';
So far. Now, I want to use the value/content of each 'MaschID' to build a reference with the "... AS ... " to another table 'ProductionSites' which has some colums named exactly like the value of MaschID. i.e. (in pseudo code):
TempData:
load
... as getTheValueOf(MaschID)
resident Maschinen
...
Unfortunately, getTheValueOf(MaschID) does not work.... 🙂
Does anybody know a/the solution?
Thanks a lot in advance
Snoman
Hello Snoman,
One workaround may be to load a table with all possible values from your field, then do a for loop and for any possible value of that first table, load a second table with renamed fields. Using for will take a lot of time though. It should look like (untested)
FieldWithValues:LOAD MaschID RESIDENT Maschinen;FOR i = 1 TO NoOfRows('FieldWithValues') SET vTempFieldName = FieldValue('MaschID', $(i)); TempData: LOAD TempField as $(vTempFieldName) RESIDENT Maschinen;NEXT
Hello Snoman,
One workaround may be to load a table with all possible values from your field, then do a for loop and for any possible value of that first table, load a second table with renamed fields. Using for will take a lot of time though. It should look like (untested)
FieldWithValues:LOAD MaschID RESIDENT Maschinen;FOR i = 1 TO NoOfRows('FieldWithValues') SET vTempFieldName = FieldValue('MaschID', $(i)); TempData: LOAD TempField as $(vTempFieldName) RESIDENT Maschinen;NEXT
Thanks for the quick response Miguel and thanks for this idea. It'll gonna really time comsuming because I have quite huge tables... but your idea brought me to some more searching and I got this posting from John Witherspoon touching the topic under "dynamically load".
I'll build my lines and will then post them here.
Thanks!
Best
Snoman