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: 
Not applicable

How to modify the same values in more than hundred distinct fields?

Hello everyone!

I have a data base with more than hundred fields, each one with exactly the same values sets.

I have to change some values on every field. For example, "OK" instead of "Yes", as I show on the example below:

Screen Shot 09-30-16 at 11.40 AM.JPG

* It's not the real situation above (I've created this example just to illustrate the problem. In fact, the real fields are a lot of different questions, as "Do you like to work here?")

How can I do this through Qilkview's load script?

I know if I have to do this in just one field is quite simple. But if I want to do this in more than hundred distinct fields at once?


Tks!

13 Replies
sunny_talwar

Try this:


Table:

CrossTable(Question, Answer)

LOAD * INLINE [

    ID, Do you believe working here for the next 5 years?, Do you like to work here?, Do you feel motivated?

    ID01, Yes, No, Maybe

    ID02, Maybe, Yes, Maybe

    ID03, No, Yes, Maybe

    ID04, No, Yes, Maybe

    ID05, No, No, Maybe

    ID06, Yes, No, Maybe

    ID07, Maybe, No, No

    ID08, Yes, Yes, Yes

    ID2560, Yes, Yes, Yes

];

NextTable:

NoConcatenate

LOAD ID,

  Question,

  If(Answer = 'Yes', 'OK', Answer) as Answer

Resident Table;

FinalTable:

LOAD Distinct ID

Resident NextTable;

FOR i = 1 to FieldValueCount('Question')

  LET vQuestion = FieldValue('Question', $(i));

  Left Join (FinalTable)

  LOAD ID,

  Answer as [$(vQuestion)]

  Resident NextTable

  Where Question = '$(vQuestion)';

NEXT

DROP Tables Table, NextTable;

marcus_sommer

This could be done within a loop, like:

for i = 0 to nooftables()

     let vTableName = tablename($(i));

     for ii = 1 to nooffields('$(vTableName)')

          let vFieldName = fieldname($(ii), '$(vTableName)');

          MAP $(vFieldName) USING YNMap;

     next

next

- Marcus

Not applicable
Author

Great, Sunny

That's what I'm looking for.

Thanks a lot!

Not applicable
Author

Hello, Marcus

The Sunny's approach was more suitable for me.

Thanks anyway