Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Name | UsedHours |
---|---|
A | 10 |
B | 15 |
C | 20 |
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.
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
Hi soha,
Concat() is an aggregation function hence you need a Group By clause..
- Ralf
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
HI there,
if you comment out this part:
It works fine, based on my understanding of your issue, see the attached:
Here is your application attached as well (PFA)
Best,
Sunny
Regards
MR
Hi,
All you have to do is remove the * (Start), in the Final table. This is not required
Hi,
Thank you for your explantions