Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
capriconuser
Creator
Creator

Capitalize column names in table

i have 10-11 tables and in each table i have columns .. also expression now  also did rename expression with label like this 

"Salary" now i want all column names in capitalize like SALARY so this is difficult for me to look on each table and capitalize each column so is this possible to capitalize column name globally ?

9 Replies
pradosh_thakur
Master II
Master II

use the below script from the thread may be

https://community.qlik.com/t5/New-to-QlikView/convert-column-name-to-upper-case/td-p/882695

Learning never stops.
capriconuser
Creator
Creator
Author

will you please post solution here.. and secondly i dont want to do in script .. is there alternate way 

pradosh_thakur
Master II
Master II

how can you capitalize the column names in UI and not in script? 

 

Please modify the script. It is copied from the script in the post above mentioned

Directory;

FILE:

load * inline [

file, table

b.xlsx, B_TABLE

a.xlsx, A_TABLE

c.xlsx,C_TABLE

];

 

// loop and read excel files

for file=0 to NoOfRows('FILE')-1;

  let filename=Peek('file', $(file), 'FILE');

  let tablename=Peek('table', $(file), 'FILE');

  $(tablename):

  load * from $(filename)

  (ooxml, embedded labels, table is Sheet1);

 

  // loop on table fields to build the "rename as" for every field 

  let s = '';

  for field=1 to NoOfFields('$(tablename)');

  let s = '$(s)'

  & if(len('$(s)')>0, ',' & chr(10), '')

  & '[' & FieldName($(field), '$(tablename)') & ']'

  & ' as ' & '[' & upper(FieldName($(field), '$(tablename)')) & '] ';

  NEXT field;

 

  // read table using the "rename as"

  rename table $(tablename) to TMP;

  $(tablename):

  NoConcatenate load

  $(s)

  Resident TMP;

 

  DROP Table TMP;

 

NEXT file;

Learning never stops.
capriconuser
Creator
Creator
Author

so i have 3 + scripts so on every scripts i paste this ?

/ loop on table fields to build the "rename as" for every field 

  let s = '';

  for field=1 to NoOfFields('$(tablename)');

  let s = '$(s)'

  & if(len('$(s)')>0, ',' & chr(10), '')

  & '[' & FieldName($(field), '$(tablename)') & ']'

  & ' as ' & '[' & upper(FieldName($(field), '$(tablename)')) & '] ';

  NEXT field;

pradosh_thakur
Master II
Master II

what do you mean by 3 scripts? In every app you need to use this once as per my understanding. You can see your scripts better so please take a call on that as per your requirement.

PS. Please take back up before trying anything
Learning never stops.
capriconuser
Creator
Creator
Author

means i have a multiple scripts in qlikview so want to ask in each scripts i paste or this or 

 

Untitled.png

pradosh_thakur
Master II
Master II

you have to paste this one time per app and the for loop will take care of everyhting
Learning never stops.
capriconuser
Creator
Creator
Author

ok in the loop there is tablename so here i write my tablename or i just paste this with "tablename" text?

capriconuser
Creator
Creator
Author

and this shows an error when i paste this 

let s = '';

for field=1 to NoOfFields('$(tableabc)');

let s = '$(s)'

& if(len('$(s)')>0, ',' & chr(10), '')

& '[' & FieldName($(field), '$(tableabc)') & ']'

& ' as ' & '[' & upper(FieldName($(field), '$(tableabc)')) & '] ';

NEXT field;