Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Learnerr
Contributor III
Contributor III

Re: Concatenate two fields

Hi,

 

Good days,

 

I extract data from SQL.

In the Select section i have 2 fields called "Explanation" and "Group". 

In the LOAD part i would like to combine both fields as they have similar parts within them. I wrote LOAD part like this:

LOAD Distinct

Explanation& Group as Groups

 

When i run this code in the front i create a listbox with the Field of "Groups" but it brings me double things under it.

Such as : Explanation and Group contains a field called linkedin and it shows in the list box as LinkedinLinkedin.

What can i do to prevent that double thing?

 

I wrote my code like this but it doesnt work:

 

CONCATENATE

Table:
Load Distinct
MenuId,
Explanation as Groups,

Group as Groups


;
SELECT
MenuId,
Explanation,
Group

FROM XYZ

Thanks in advance.

Kind Regards.

1 Solution

Accepted Solutions
chris_djih
Creator III
Creator III

To clear some things up.

Concatenate means that you simply append your field or table. So by concatenating your table you just add new lines at the end. If you concatenate two fields with "&" you just attach the content of the fields.

What you are may looking for is way to handle the both fields as if they were the same field?
Then the way to go in qlik is: give them the same name -> they are interpreted as the same field (as you already tried). Since it isn't allowed to give a name twice within a table you have to load this in 2 steps:

 

table:
Load distinct
MenuId,
Explanation as Groups
; SELECT .... FROM XYZ;

concatenate(table)
Load distinct
MenuId,
Group as Groups
; SELECT ... FROM XYZ;

 

In this case you may will get two lines of data for each menuId.

I wonder if you may want to achieve smething like this: Take the value of Explanation, if it is null then take vlaue of Group ?
Then you can load it whith a single load statement and just use the alt()-statement:

 

Load
  MenuId,
  alt(Explanation, Group) as Groups;
SELECT ... FROM XYZ;

 



If you found help, mark the correct answer and give some likes to ALL contributors, that tried to help.

View solution in original post

2 Replies
chris_djih
Creator III
Creator III

To clear some things up.

Concatenate means that you simply append your field or table. So by concatenating your table you just add new lines at the end. If you concatenate two fields with "&" you just attach the content of the fields.

What you are may looking for is way to handle the both fields as if they were the same field?
Then the way to go in qlik is: give them the same name -> they are interpreted as the same field (as you already tried). Since it isn't allowed to give a name twice within a table you have to load this in 2 steps:

 

table:
Load distinct
MenuId,
Explanation as Groups
; SELECT .... FROM XYZ;

concatenate(table)
Load distinct
MenuId,
Group as Groups
; SELECT ... FROM XYZ;

 

In this case you may will get two lines of data for each menuId.

I wonder if you may want to achieve smething like this: Take the value of Explanation, if it is null then take vlaue of Group ?
Then you can load it whith a single load statement and just use the alt()-statement:

 

Load
  MenuId,
  alt(Explanation, Group) as Groups;
SELECT ... FROM XYZ;

 



If you found help, mark the correct answer and give some likes to ALL contributors, that tried to help.
Learnerr
Contributor III
Contributor III
Author

Hi,

 

The first code block that You shared worked and now i removed all the recurring fields in the front part. It increased my motivation. Thank you so much and have a nice day.

 

Regards