You can achieve this using cross table.
I wrote a sample script as an example. In this piece of code, I wrote a table using inline and store, but you can start from the second step, using crosstable on your original tables:
//Creation of Test Table
LOAD * INLINE [
STUDY, TYPE, BUIDING1, BUILDING2, BUILDING3
1, A, 200, 300, 400
1, B, 100, 50, 20
1, C, 15, 90, 400
2, A, 15, 32, 200
2, B, 200, 100, 150
2, C, 50, 100, 70
Store Test into Test.qvd;
drop table Test;
//QVDs will be read to simulate a source file
//Cross table could be done in the original Load Inline
CrossTable(tempBuilding, Value, 2)
//At this point tempBuildings has the Fields: STUDY, TYPE, tempBuilding and Value
TYPE, Right(tempBuilding,1) as Building,
drop table tempBuildings;
Hope this helps,
Yes it is possible. See attachment. You should look in the help at the Crosstable statement and the string functions.
Crosstable.qvw 149.0 K
Im sorry, this was a missunderstanding.
the example i provided was a bit misleading.
im not looking for a crosstable statement or a string function. this wouldnt be the problem (there are tons of examples for this here)
im looking for something like
"Right(tempBuilding,1) as Building,"
but the source should be the field name (tempBuilding) and not the content.
something that just reads the number from the name of the field
LET Numfield= Right(field7,1)
Right(test_table,1) , so its gets the last digit (or char) of every fieldname in "test_table"
im sorry for the missunderstanding.
Not quite sure I understand... when you write your Load statement, then you know the field names, so you might as well hard-code the number in the script. Or what am I missing?
Anyway, if you loop over the fields, then you can use the FieldNumber() and FieldName() functions, and in your case it could then be
Right (FieldName(2, 'Table'),1) as Building