Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Fiber
Contributor
Contributor

Concatenate word in alphabetical order within a field

Hi all,

There's a long time since I posted my last question and this community has always been really helpful. I hope to be typing this in the correct board. There I go...

Simple exercise: I have an inline  table with just one field and two rows

tabla:
load * inline [
concept
'|ROJO| |CRIO| |COCHE|'
'|AZUL| |AVE|']
;

My purpose is to get a table with an extra field where the words will be sorted alphabetically

Concept Concept sorted
|ROJO| |CRIO| |COCHE| |COCHE| |CRIO| |ROJO|
|AZUL| |AVE| |AVE| |AZUL|

 

I've been working with SubStringCount and Subfield formulas unsuccessfully. I suppose the will be a loop at some point, but I've never done it before.

Did anybody prepare something similiar before?

Thanks for your help

Fiber

1 Solution

Accepted Solutions
MarcoWedel

Hi,

one solution could be:

 

MarcoWedel_0-1658583944353.png

 

tabla:
LOAD concept,
     Concat('|'&substr&'|',' ') as [concept sorted]
Group By concept;
LOAD *,
     PurgeChar(SubField(concept,'| |'),'|') as substr
INLINE [
    concept
    |ROJO| |CRIO| |COCHE|
    |AZUL| |AVE|
    |ABC| |GHI| |DEF| |JKL|
    |JKL| |DEF| |GHI| |ABC|
    |PQR| |MNO|
    |STU|    
];

 

hope this helps

Marco

View solution in original post

2 Replies
MarcoWedel

Hi,

one solution could be:

 

MarcoWedel_0-1658583944353.png

 

tabla:
LOAD concept,
     Concat('|'&substr&'|',' ') as [concept sorted]
Group By concept;
LOAD *,
     PurgeChar(SubField(concept,'| |'),'|') as substr
INLINE [
    concept
    |ROJO| |CRIO| |COCHE|
    |AZUL| |AVE|
    |ABC| |GHI| |DEF| |JKL|
    |JKL| |DEF| |GHI| |ABC|
    |PQR| |MNO|
    |STU|    
];

 

hope this helps

Marco

Fiber
Contributor
Contributor
Author

It's amazing Marco!

Thank you so much for your help. It works!!

Now I have to study how you did it and adapt it to my code, where the real table has +39k rows with over 15k words

Fiber