Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Load variable

Hi community,

I have many different files with the same questions, but different wording.

They are started from qID_2_blabla or qID_3_blabla.

I want, if any question started from qID_2_ save as AAA, if any question started from qID_3_ save as BBB.

Do you have any ideas how it easy to do?

Regards,

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi Vladimir,

I added mapping table and applymap in the script so it can convert Qnnn to the specific wording per map.  As for hte load form SQL - it doesn't matter much.  If you load from different tables that have same Q numbers with different wordings, you'll have to repeat this script for each table (except the map of course).

Regards,

Michael

View solution in original post

15 Replies
Anonymous
Not applicable
Author

Vladimir,

You can use mapping.  For example:

MyMap:
MAPPING LOAD * INLINE [
A,           B
qID_2_, AAA
qID_3_, BBB
];

Data:
LOAD
...
applymap('MyMap', left(FieldName,6)) as NewField
...

RESIDENT ...

Regards,
Michael

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     If they are the field values when you can simply write if statement.

     Another approach you can use if of for loop.

     If you know how much questions are there, then run a loop and check for the questions and bucket them accordinly.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anonymous
Not applicable
Author

Hi Michael,

It won't be work, because some questions have more than 6 digits like it. qID_385_.

My idea to create universal load, where I only select which the file I want to load.

Thanks,

Anonymous
Not applicable
Author

Hi,

I know only numbers without wording. Because writing is changed from time to time.

I'd like to create universal load, where I can work with constant variable.

Regards,

Anonymous
Not applicable
Author

There is no logical difference...  There is some technical difference - you need to find the position of the second '_', and cut all after it.

left(Field, index(Field,'_',2))

Now, you can use it as is, or convert it to something shorter using AutoNumberHash128:

AutoNumberHash128(left(Field, index(Field,'_',2))) as NewField

Anonymous
Not applicable
Author

Thanks for reply,

I used both your ideas.

AutoNumberHash128(left(Field, index(Field,'_',2))) as NewField

Result 1 or 2


left(Field, index(Field,'_',2))

listbox is empty

Anonymous
Not applicable
Author

It implies that there is no two '_' characters in field values...  Can you upload an example?

Anonymous
Not applicable
Author

Hi Michael,

Please find the attached file.

Regards,

Vladimir

Anonymous
Not applicable
Author

Please also find xls file.

Thanks,