Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
zagzebski
Creator
Creator

Load only fields with specific prefix

Is there any (automated) way of doing a load of fields with specific prefixes. I have a table (example Table A below) that is constantly modified and rather than have to add and removes fields every time it would be great screen the fields (as an example in Table B below where it would automatically only pull in fields beginning with MI):

For example:

Table A:

Load

MI Customer,

MI Region ,

MI Amount,

Sales,

Employee,

Budget

From Table_Source;

Table B:

Load

{only fields beginning in MI}

Resident Table A:

Labels (1)
1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Yes, that's possible.

[Table A]:

LOAD * INLINE [

MI One, MI Two, MI Three, Four, Five

1,2,3,4,5

];

LET vFields = NoOfFields('Table A');

For j=1 to $(vFields)

    LET vField = FieldName($(j),'Table A');

    WHEN FindOneOf('$(vField)','MI') LET vFieldList = '$(vFieldList)' & ', ' & '[$(vField)]';

next

LET vFieldList = Mid('$(vFieldList)',2);

[Table B]:

LOAD

     $(vFieldList) 

RESIDENT

     [Table A]

;

SET vFieldList=;


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Yes, that's possible.

[Table A]:

LOAD * INLINE [

MI One, MI Two, MI Three, Four, Five

1,2,3,4,5

];

LET vFields = NoOfFields('Table A');

For j=1 to $(vFields)

    LET vField = FieldName($(j),'Table A');

    WHEN FindOneOf('$(vField)','MI') LET vFieldList = '$(vFieldList)' & ', ' & '[$(vField)]';

next

LET vFieldList = Mid('$(vFieldList)',2);

[Table B]:

LOAD

     $(vFieldList) 

RESIDENT

     [Table A]

;

SET vFieldList=;


talk is cheap, supply exceeds demand
zagzebski
Creator
Creator
Author

Thanks!!