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

Concate all fields to a single field excluding null values

Hi all,

I have a data like this

SNOABCDEFGHIJ
11.45821.23554.415
21.45821.885854.2854.45552.2241.2253.23543.4656.32551.4536
32.34532.423 4.4543.45432.445453.5762.25454.32432.5366.3411.635
41.4578
54.24255
63.42546344344
725442233.1222.222

After concate the result as below:

Capture.PNG

Here how to avoid repeated ',' here some fields having null values:

expression was which is i used : A&','&B&','&C&','&D&','&E&','&F&','&G&','&H&','&I&','&J

I want the only single comma between two values, please suggest


Thanks in advance

Regards,

Gopi

1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

One way may be using Cross Table try like

PivotEg:

CrossTable(DataField, Value)

LOAD SNO,

     A,

     B,

     C,

     D,

     E,

     F,

     G,

     H,

     I,

     J

FROM

[..\Desktop\Sample.xlsx]

(ooxml, embedded labels, table is Sheet1);

View solution in original post

7 Replies
Gopi_E
Creator II
Creator II
Author

Hi Sunny can you look on to this

stalwar1

Thanks in advance

marcus_sommer

There are various ways possible. The easiest is probably to wrap your field-concat with multiple replace-statements like:

replace(replace(A&','&B&','&C&','&D&','&E&','&F&','&G&','&H&','&I&','&J, ',,', ','), ',,,', ',')

Also possible is to replace the commas with a mapsubstring() or loading your data with a crosstable and concat() it result again. Both approaches will need additionally load-statements but they will be more handy as the replace-chain if you hadn't just a few fields else many of them.

- Marcus

Gopi_E
Creator II
Creator II
Author

Hi Marcus,

Thanks for reply

can you elaborate crosstable approach

I tried by using crosstable but it didn't work for me can you suggest

FieldsAddData:

CrossTable(attr,Data,10)

LOAD SNO,

     A,

     B,

     C,

     D,

     E,

     F,

     G,

     H,

     I,

     J,

         

FROM

[..\..\Vinod SampleData\AddAllFieldsData.xlsx]

(ooxml, embedded labels, table is Sheet1);


Left Join(FieldsAddData)

LOAD Distinct

SNO,

Concat(Data,',') as AD

Resident FieldsAddData Where Len(Data)>0 Group By SNO;

Drop Fields attr,Data;


is there any mistake here.



vishsaggi
Champion III
Champion III

One way may be using Cross Table try like

PivotEg:

CrossTable(DataField, Value)

LOAD SNO,

     A,

     B,

     C,

     D,

     E,

     F,

     G,

     H,

     I,

     J

FROM

[..\Desktop\Sample.xlsx]

(ooxml, embedded labels, table is Sheet1);

marcus_sommer

In general it looked ok. but your third parameter within the crosstable is 10 and it should be 1 because you have just one leading field.

- Marcus

Gopi_E
Creator II
Creator II
Author

Hi Vishwarath,

Thanks for the reply, Now correct my crosstable approach and its working now.

Regards,

Gopi

Gopi_E
Creator II
Creator II
Author

Hi Marcus,

Thanks for the reply,

I corrected my crosstable third argument.

Now it is working

Regards,

Gopi