I have 2 Fields and I need to combine them in one field. Is it possible to get this result in Qlik Sense?
I do not want concatenate but get the result in table
I have 2 Fields and I need to combine them in one field. Is it possible to get this result in Qlik Sense?
I do not want concatenate but get the result in table
Levi's should be accepted as the answer but I just wanted to point out another option, which is to use the CrossTable() prefix, which can be used to "pivot" the values of 2 or more columns into a single column. This method can be useful if the columns you need to combine are already in a single table.
The script you can use in the Data Load Editor may look like this:
[Table 1]:
Load * Inline [
Activity , Activity Code
A , A01
B , A03
C , A05
D , B02
E , B06
, B03
, C01
, C03
, C08
, D24
, D21
, D30
, E11
, E15
, E22
];
[Pivoted table]:
CrossTable ([throwaway 1], [Combined], 1)
Load
1 as [throwaway 2]
, [Activity]
, [Activity Code]
Resident [Table 1];
Drop Fields [throwaway 1], [throwaway 2];
[Table 1]
is just the data as it appears in your screenshot. Below that, the [Pivoted table]
is a table that loads three fields:
1 as [throwaway 2]
- this is so that we have at least one qualifier field, or unchanged dimension, to group the combined columns on (see the Qlik Help page on the CrossTable prefix to read more about why this is needed). I named it [throwaway 2]
because we won't need it after this.[Activity]
- One of the columns we want to combine.[Activity Code]
- The other column we want to combine.The CrossTable()
is going to result in an attribute field called [throwaway 1]
(so named because we won't need it after this) and a data field called [Combined]
, which will be our new combined field!
After we load this, our results are just what we'd expect:
It's not particularly clear what the source is and how the data is structured, but you can
JOIN
without a key to flatten. Example:This will result in a table with the structure of: