Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
shekhar_analyti
Specialist
Specialist

How to convert a single row into multiple based on a delimiter condition in one particular column ?

Hi All ,

How to convert a single row into multiple based on a delimiter condition in one particular column ?

Capture.PNG

Field Person has values delimited . But Delimiter type is not fixed .

Thanks & Regards

Shekar

31 Replies
luismadriz
Specialist
Specialist

Good, is not that long of a list, you can then apply Deva's or KC's solutions. You're just going to have a long sentence

The only thing you need to remember is to add Distinct to the load to remove duplicates

I hope this helps,

Cheers,

Luis

mato32188
Specialist
Specialist

Have you tried that? Try to apply this logic in code above that have been provided by Devarasu R.

BR

Martin

ECG line chart is the most important visualization in your life.
maxgro
MVP
MVP

you can use the mapsubstring to replace the delimiters

and then the sublfield

map2:

mapping

LOAD *

Inline [

From, To

~, @

!, @

@, @

#, @

., @

' ',@

',',@

-,@

] ;

t1:

LOAD * INLINE [

Doornbr,Date,Person

22456,12/12/2017,"Sam,Krish,Tony"

22457,13/12/2017,"Sam!Bill.Munoj"

22458,14/12/2017,"Murphy#Linda"

22459,15/12/2017,"Numerov"

22459,12/12/2017,"Joy#Gracy"

22461,14/12/2017,"Tina~Deva"

22461,14/12/2017,"Tina.Deva"

22461,14/12/2017,"aaa bbb"

1,15/12/2017,"ccc-ddd"

];

t2:

Productmodels:

LOAD

*,

Subfield(MapSubString('map2', Person), '@') as Person2

Resident t1;

DROP Table t1;


1.png

luismadriz
Specialist
Specialist

Hi,

Below is what I was going to propose but it's not working properly and I'm not sure why. The order in which I create the string vDelimiters affects the results.

If I use vDelimiters = '.#,'; Then I get the 13 records as requested

but if I change it to vDelimiters = ',.#'; then I get 12 records


I may be missing something!!! Maybe someone else could troubleshoot because I need to go home now


vDelimiters = '.#,';

For i = 1 to 3

    vChar = MID(vDelimiters,i,1);

    Load Distinct Doornbr,

                  Date,

                  SubField(Person,'$(vChar)') as Person;

Next;

Load * Inline [

Doornbr,Date,Person

22456,12/12/2017,"Sam,Krish,Tony"

22457,13/12/2017,"Sam,Bill.Munoj"

22458,14/12/2017,"Murphy#Linda"

22459,15/12/2017,"Numerov"

22459,12/12/2017,"Joy.Gracy"

22461,14/12/2017,"Tina#Deva"

22461,14/12/2017,"Tina#Deva"];

shekhar_analyti
Specialist
Specialist
Author

Thanks Massimo . Please attach sample .

shekhar_analyti
Specialist
Specialist
Author

Is this not a dependency ? Everytime i have to update this , if a new delimiter comes in picture

map2:

mapping

LOAD *

Inline [

From, To

~, @

!, @

@, @

#, @

., @

' ',@

',',@

-,@

] ;

shekhar_analyti
Specialist
Specialist
Author

Please Help to make it dynamic .. stalwar1

sunny_talwar

What exactly do you mean when you say to make this dynamic?

shekhar_analyti
Specialist
Specialist
Author

Thank you Sunny the for reply .

Dynamic means ... irrespective of type of delimiter (which we have discussed) . script should handle it and generate output table as expected .

shekhar_analyti
Specialist
Specialist
Author

these ~!@#$%^&*()_+-=';":}{][\|?><,./ , Space and hyphen as well