Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
maprinci
Contributor II
Contributor II

How do I turn a text field that contains many variables into separate variables in Qlik Sense?

am working with a dataset where one variable has a number of variables within it. I need to parse through the text to extract each variable value.

Current:

maprinci_0-1623165949142.png

Desired:

maprinci_1-1623165969664.png

Thank you for any help you can provide!

2 Replies
chrismarlow
Specialist II
Specialist II

Hi,

Your Extra column looks like JSON, if so have you seen the following thread;

Solved: Qlik Sense parsing of a json field - Qlik Community - 1795740

Cheers,

Chris.

Taoufiq_Zarra

Hi @maprinci ,

you can use this version :

Tmp:


load *, purgechar(subfield(newExtrat,':',1),'{}"') as Field,purgechar(subfield(newExtrat,':',2),'{}"') as Vuale; 
load *,subfield(Extra,',') as newExtrat inline [
Customer;Group; Extra
1;A1;{"Field1":"A","Field2":"B","Field3":"C"}
2;A2;{"Field1":"D","Field2":"E","Field3":"F"}
3;A3;{"Field1":"A","Field2":"G","Field3":"D"}
](delimiter is ';');
left join load count(newExtrat) as Tm1 resident Tmp group by Customer;


CombinedGenericTable:

Load distinct Customer,"Group" resident Tmp;


DATA:
 generic LOAD
 
     Customer, 
     "Group", 
     Field,
     Vuale
     
     Resident Tmp;
     
 Drop Table   Tmp; 
 


   

FOR i = NoOfTables()-1 to 0 STEP -1

  LET vTable=TableName($(i));
  //trace $(i) - '$(vTable)';
  IF WildMatch('$(vTable)', 'DATA.*') THEN 

  LEFT JOIN ([CombinedGenericTable]) LOAD distinct * RESIDENT [$(vTable)];

  DROP TABLE [$(vTable)];

  ENDIF 

NEXT i

 

output:

Taoufiq_Zarra_0-1623167545867.png

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉