Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
heid_f
Contributor III
Contributor III

Array to string conversion in mapping

Hey there,

I want to create a comma-separated string of values for my articles using a Mapping Table.

 

Is that possible? Here an example / Pseudo-Code

Mapping_Zustaende:
Mapping LOAD
	BBT_WflLockStatusInst.Owning_Obj	As %KEY_S_Artikel_BBT_WflLockStatusInst,
    COMMA-SEPARATED-STRING(BBT_WflLockStatusInst.Zustand)
From
	$(ImportPfad)BBT_WflLockStatusInst.qvd (qvd)
;

 

Thanks for your replies and Best Regards.

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Ah, you want to create a string of comma separated value:

LOAD
    article,
    concat(information, ',', information) as [commaseperatedstring]
RESIDENT
    Informations
GROUP BY
    article;

 


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

You want to replace the key value in the target table with the comma separated string? That's no problem. What you cannot do with a mapping table is replace on key with multiple values. A field can have only one value. If you want to generate separate records in which in each record the key is replaced with a part of the comma separated string then you need to create a regular table and join that to the other table.

 

MainTable:
LOAD %KEY_S_Artikel_BBT_WflLockStatusInst,
...other fields...
FROM $(SomePath)SomeQvd (qvd);

LEFT JOIN (MainTable)

//ExplodedCommaSeparated:
LOAD
	BBT_WflLockStatusInst.Owning_Obj	As %KEY_S_Artikel_BBT_WflLockStatusInst,
    SubField(COMMA-SEPARATED-STRING(BBT_WflLockStatusInst.Zustand),',') as CSS_Part
From
	$(ImportPfad)BBT_WflLockStatusInst.qvd (qvd)
;

 

 


talk is cheap, supply exceeds demand
heid_f
Contributor III
Contributor III
Author

Hey,

thanks for you reply. I think I explained it wrong.

I have a table with my additional informations about my articles (one article can have several informations)

Informations:
LOAD * INLINE[
    article, information
    1, a
    2, b
    3, c
    1, d
    1, b
    2, e
    2, f
    1, g
]

 

Then I have a Table with my articles. Now I want to add to this table one column with all informations to every articles. At example I want to get:

Articles:
1 | a,d,b,g
2 | b,e,f
3 | c

 

Is this possible with a Mapping Table?

Gysbert_Wassenaar

Ah, you want to create a string of comma separated value:

LOAD
    article,
    concat(information, ',', information) as [commaseperatedstring]
RESIDENT
    Informations
GROUP BY
    article;

 


talk is cheap, supply exceeds demand