Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
 didierodayo
		
			didierodayo
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hello,
I don't know if this is possible in Qlik but I like to ask anyway.
I am trying to write a lable expression that I can use to change th
e field name
dynamically inside the table
I have a lot of fields to display and they all have 'OLD_' in front of them.
in the Label box can I write something like =Subfield(getthefield(),'OLD_',2)
so I can just paste it in all the label boxes.
any suggestion is welcomed.
Cheers

 
					
				
		
 adamdavi3s
		
			adamdavi3s
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Just pondering this, you could always reverse this instead of qualifying in the first place, then you can work around the key fields issue.
for example you'd have to run this after each table load to do the 'qualifying', this code assumes your key fields are prefixed 'KEY'
Load table1 blah;
Let vTableName = TableName(table1);
For f = 1 to NoOfFields('$(vTableName)')
let vFieldOld = FieldName($(f),'$(vTableName)');
let vFieldNew = '$(vTableName).$(vFieldOld)';
if(left('$(f)',3)<>'KEY') then
RENAME FIELD $(vFieldOld) to $(vFieldNew);
else
endif;
Next f;
Then at the end just run the original script:
For vTable = 0 to NoOfTables() -1
Let vTableName = TableName(vTable);
For f = 1 to NoOfFields('$(vTableName)')
let vFieldOld = FieldName($(f),'$(vTableName)');
let vFieldNew = Replace('$(vFieldOld)','$(vTableName)'&'.','');
if(left('$(f)',3)<>'KEY') then
RENAME FIELD $(vFieldOld) to $(vFieldNew);
else
endif;
Next f;
Next ;
That is possible when you try something like below
=SubField('Old_Item','_',-1) //Here, this is complex and kills the performance. Why not simply Item on label. Any problem over here
In fact, This is very typical to write for all Dimensions, I would love to use Script level using Preceding load via All field to single field
 
					
				
		
 jonathandienst
		
			jonathandienst
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Although you can apply labels to field names, I don't think it is possible to do it the way you suggest. It is fairly easy to rename the fields in the load script. Build a mapping table of the old and new names (fo example, in a spreadsheet), load this mapping and use the rename option Rename Fields Using MapTable.
 
					
				
		
 didierodayo
		
			didierodayo
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi Jonathan.
Reason I am not using the applymap is because I am getting the field names after Using Qualify on multiple qvd load.
These are big tables so it takes awhile to rename the fields manually.
Can we applymap after Qualify *; ?
What is the best ways to rename fields back to their filebasename after Using Applymap?
Thanks
 
					
				
		
 didierodayo
		
			didierodayo
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi Anil ,
I need something generic that could be applied to all the dimensions because I have many of them .
I think it is not possible at this stage.
I will try the apply map suggested by Jonathan.
Thanks
 
					
				
		
 adamdavi3s
		
			adamdavi3s
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi Didier,
I wrote a little script to do this in the load script, the only thing you have to remember is that you can not rename key fields
For vTable = 0 to NoOfTables() -1
Let vTableName = TableName(vTable);
For f = 1 to NoOfFields('$(vTableName)')
let vFieldOld = FieldName($(f),'$(vTableName)');
let vFieldNew = Replace('$(vFieldOld)','$(vTableName)'&'.','');
RENAME FIELD $(vFieldOld) to $(vFieldNew);
Next f;
Next ;
 
					
				
		
 didierodayo
		
			didierodayo
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Thanks Adam I'll give this a shot.
 
					
				
		
 adamdavi3s
		
			adamdavi3s
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Just pondering this, you could always reverse this instead of qualifying in the first place, then you can work around the key fields issue.
for example you'd have to run this after each table load to do the 'qualifying', this code assumes your key fields are prefixed 'KEY'
Load table1 blah;
Let vTableName = TableName(table1);
For f = 1 to NoOfFields('$(vTableName)')
let vFieldOld = FieldName($(f),'$(vTableName)');
let vFieldNew = '$(vTableName).$(vFieldOld)';
if(left('$(f)',3)<>'KEY') then
RENAME FIELD $(vFieldOld) to $(vFieldNew);
else
endif;
Next f;
Then at the end just run the original script:
For vTable = 0 to NoOfTables() -1
Let vTableName = TableName(vTable);
For f = 1 to NoOfFields('$(vTableName)')
let vFieldOld = FieldName($(f),'$(vTableName)');
let vFieldNew = Replace('$(vFieldOld)','$(vTableName)'&'.','');
if(left('$(f)',3)<>'KEY') then
RENAME FIELD $(vFieldOld) to $(vFieldNew);
else
endif;
Next f;
Next ;
 
					
				
		
 didierodayo
		
			didierodayo
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Thanks a lot Adam this second suggestion works my scenario.
 
					
				
		
 eromiyasimon
		
			eromiyasimon
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		'OLD_' &''& 'Field_name'
