Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
raajaswin
Creator III
Creator III

Concat using dynamic string

Hi all,

My Input,

KEYTEXT1TEXT2
1AB
2AB
3B
4A
5

Required Output,

KEYOUTPUT
1A,B
2A,B
3B
4A
5

Need to do it in script,

As of now am using some nested if and & operator, do we have direct function??, can we do it with concat??

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

May be try this:

data:

CrossTable(TEXT, toto, 1)

LOAD * INLINE [

KEY, A, B,C

1, A, B,1

2, A, B

3, , B ,1

4, A, ,1

5

];

LOAD

KEY,

Concat(toto, ',', AutoNumber(TEXT)) as tt

Resident data

where len(toto)<>0

Group By KEY

;

View solution in original post

14 Replies
swuehl
Champion III
Champion III

You can transform your input table using CROSSTABLE LOAD prefix into a table with structure KEY, TEXT, and TEXT ID, then aggregate (using Concat() ) this new table TEXT values Grouped by KEY.

The Crosstable Load

raajaswin
Creator III
Creator III
Author

if(isnull(TEXT1),TEXT2,if(isnull(TEXT2),TEXT1,TEXT1&','&TEXT2))

this is what am doing as of now

raajaswin
Creator III
Creator III
Author

i have many more columns and lakhs of rows like this,  I dont think cross table can be formed for this

Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

If you have more than one field change the number 1

data:
CrossTable(TEXT, toto, 1)
LOAD * INLINE [
KEY, TEXT1, TEXT2
1, A, B
2, A, B
3, , B
4, A
5
]
;


LOAD
KEY,
Concat(toto, ', ') as tt
Resident data
Where Len(toto)<>0
Group By KEY
;

Help users find answers! Don't forget to mark a solution that worked for you!
sunny_talwar
MVP
MVP

So what is the issue with this? This isn't working?

Anil_Babu_Samineni
MVP
MVP

Does this working same as this from Preceding Load

(Text1 & ',' & Text2) as Output

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
raajaswin
Creator III
Creator III
Author

Am looking for any direct function.. I will try out this way and let u know.. Thank u

raajaswin
Creator III
Creator III
Author

This will give me an additional comma, when Text 2 is blank

raajaswin
Creator III
Creator III
Author

Ya what i was doing is crct nly,, Just wanted to know is there any direct fuction for this??