Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
TosBlAk
Contributor
Contributor

Merge multiple rows into one in Qlikview

Hi all, 

I have a field that has some records I'll like to combine into one.

For example:

FieldName (Colors)            (Count) Quantity 

Light Yellow                                             4

Lemon Yellow                                         7

Chrome Yellow                                       2

Red                                                              15

Green                                                           8

 

I want Light Yellow, Lemon Yellow and Chrome Yellow  to be a single entry as "Yellow". End Result should be:

FieldName (Colors)       (Count) Quantity 

Yellow                                               13

Red                                                    15

Green                                                 8

 

How can I go about this please?

Thanks in advance. 

1 Solution

Accepted Solutions
maxgro
MVP
MVP

If you have a table X with Light, Lemon, ...... Yellow

X:
load * inline [
Colors , Quantity
Light Yellow , 4
Lemon Yellow , 7
Chrome Yellow , 2
Red , 15
Green , 8
];

 

you can group the rows when there is Yellow in the Colors field and sum the quantity


Y:
NOCONCATENATE LOAD
IF(WILDMATCH(Colors, '*yellow*'), 'Yellow', Colors) as Colors,
SUM(Quantity) AS Quantity
RESIDENT X
GROUP BY IF(WILDMATCH(Colors, '*yellow*'), 'Yellow', Colors);

DROP TABLE X;

View solution in original post

1 Reply
maxgro
MVP
MVP

If you have a table X with Light, Lemon, ...... Yellow

X:
load * inline [
Colors , Quantity
Light Yellow , 4
Lemon Yellow , 7
Chrome Yellow , 2
Red , 15
Green , 8
];

 

you can group the rows when there is Yellow in the Colors field and sum the quantity


Y:
NOCONCATENATE LOAD
IF(WILDMATCH(Colors, '*yellow*'), 'Yellow', Colors) as Colors,
SUM(Quantity) AS Quantity
RESIDENT X
GROUP BY IF(WILDMATCH(Colors, '*yellow*'), 'Yellow', Colors);

DROP TABLE X;