Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a requirement to display the list of all the field names and its maximum value length.
I have tried max(len($Field)) in front end which gives me length of the field name not the value.
I have tried loops in script tried max(len(FieldName(Field,Table)) , again it gave length of the field name not the value..
Please suggest a solution.. Front end or in script any thing is fine
My desired o/p is
Table NAme | Field Name | Maxlength |
Table1 | Field1 | 22 |
Table1 | Field2 | 10 |
Table2 | Field1 | 121 |
Table2 | Field2 | 23 |
Table2 | Field3 | 34 |
Table3 | Field1 | 20 |
Hi,
one solution on load Script :
Suppose I have those Tables :
The Script :
Table1:
load * inline [
A,B,C
1,2564,56464 dfgs
10,25,56464 dfgssd
];
Table2:
load * inline [
AA,BB,CC
1sdfd,25sdfs64,56fdsfds464 dfgs
1fsdf,2ff5,56dfsdffsdfsdfd464 dfgssd
];
FOR i = NoOfTables()-1 to 0 STEP -1
LET vTable=TableName($(i));
FOR j =1 to NoOfFields('$(vTable)')
FieldMax:
let vFieldName=FieldName($(j),'$(vTable)') ;
//let vfakue=Peek($(vname),'$(vTable)');
LOAD
len($(vFieldName)) as lengthfield,
'$(vTable)' as [Table Name],
'$(vFieldName)' as [Field Name]
RESIDENT [$(vTable)];
NEXT j
NEXT i
outputFieldMax:
noconcatenate
load [Table Name],[Field Name], max(lengthfield) as Maxlength resident FieldMax group by [Table Name],[Field Name] ;
drop table FieldMax;
The output :
hi,
Find the Max length of the fields in each table while load itself and sort by Descending order.
Do the Resident load where rowno=1 and concatenate as single table and present in the dashboard.
Regards
Yogesh.
Hi,
one solution on load Script :
Suppose I have those Tables :
The Script :
Table1:
load * inline [
A,B,C
1,2564,56464 dfgs
10,25,56464 dfgssd
];
Table2:
load * inline [
AA,BB,CC
1sdfd,25sdfs64,56fdsfds464 dfgs
1fsdf,2ff5,56dfsdffsdfsdfd464 dfgssd
];
FOR i = NoOfTables()-1 to 0 STEP -1
LET vTable=TableName($(i));
FOR j =1 to NoOfFields('$(vTable)')
FieldMax:
let vFieldName=FieldName($(j),'$(vTable)') ;
//let vfakue=Peek($(vname),'$(vTable)');
LOAD
len($(vFieldName)) as lengthfield,
'$(vTable)' as [Table Name],
'$(vFieldName)' as [Field Name]
RESIDENT [$(vTable)];
NEXT j
NEXT i
outputFieldMax:
noconcatenate
load [Table Name],[Field Name], max(lengthfield) as Maxlength resident FieldMax group by [Table Name],[Field Name] ;
drop table FieldMax;
The output :
Yes This is working. Thanks..
But it loads all the columns again.. like if there are 200 columns in the dashboard. It loads all the columns again.. I am using this solution as of now. But please let me know if something can be done in a optimized way either in front end or scripting
yes!
Table1:
load * inline [
A,B,C
1,2564,56464 dfgs
10,25,56464 dfgssd
];
Table2:
load * inline [
AA,BB,CC
1sdfd,25sdfs64,56fdsfds464 dfgs
1fsdf,2ff5,56dfsdffsdfsdfd464 dfgssd
];
FOR i = NoOfTables()-1 to 0 STEP -1
LET vTable=TableName($(i));
FOR j =1 to NoOfFields('$(vTable)')
FieldMax:
let vFieldName=FieldName($(j),'$(vTable)') ;
//let vfakue=Peek($(vname),'$(vTable)');
LOAD
Max(len($(vFieldName))) as lengthfield,
'$(vTable)' as [Table Name],
'$(vFieldName)' as [Field Name]
RESIDENT [$(vTable)];
NEXT j
NEXT i
A UI solution would be a tricky one but possible.
$(=concat('if($Field=' & chr(39) & $Field & chr(39) & ',Max({1}Len([' & $Field & ']))', ',') & concat(right($Field&')',1)))
Credit goes to @rbecher