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

Concat() in Script

Hi All,

I have 2 fields Name and Used Hours. I loaded these two in my Script.

I want to create a concatenated string using these fields.

EX.

NameUsedHours
A10
B15
C20

Expected String: A-10,B-15,C-20

To get this first I Created a following field:

Load * inline [
Name, Used_Hour
A,10
A,20
B,25
C,15
B,20]
;

Table:
LOAD Name & '-' & Used_Hour as NewField
,*
Resident Tab;
Drop Table Tab;

For Creating a Desired field when I am using Concat function its throwing error message:

Final:

Load Concat(NewField,',') as Newfield2
,*
Resident Table;
Drop Table Table;

Please help.

Thanks.

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Tab:

Load * inline [

Name, Used_Hour

A,10

A,20

B,25

C,15

B,20];

Table:

LOAD Name & '-' & Used_Hour as NewField

,*

Resident Tab;

Drop Table Tab;

Final:

Load Concat(NewField,',') as Newfield2

Resident Table;

Concat needs a group by statement or you are basically concatenating everything in that particular field in which case you cannot add any other field to the Final table because it won't do the grouping.

HTH

Best,

Sunny

View solution in original post

7 Replies
rbecher
MVP
MVP

Hi soha,

Concat() is an aggregation function hence you need a Group By clause..

- Ralf

Astrato.io Head of R&D
sunny_talwar

Try this:

Tab:

Load * inline [

Name, Used_Hour

A,10

A,20

B,25

C,15

B,20];

Table:

LOAD Name & '-' & Used_Hour as NewField

,*

Resident Tab;

Drop Table Tab;

Final:

Load Concat(NewField,',') as Newfield2

Resident Table;

Concat needs a group by statement or you are basically concatenating everything in that particular field in which case you cannot add any other field to the Final table because it won't do the grouping.

HTH

Best,

Sunny

awhitfield
Partner - Champion
Partner - Champion

HI there,

if you comment out this part:

It works fine, based on my understanding of your issue, see the attached:

sunny_talwar

Here is your application attached as well (PFA)

Best,

Sunny

mrossoit
Creator II
Creator II

Regards

MR

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

All you have to do is remove the * (Start), in the Final table. This is not required

Not applicable

Hi,

Thank you for your explantions