Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Turn several rows into one

I have a straight table with sales info in columns like this:

SaleID Amount SalesPerson Region

A sale can have multiple Sale Persons on it. So I end up with 2 rows for 1 sale. Like this:

SaleID Amount SalesPerson Region

1 100 Tim USA

1 100 Sam USA

I would like to have it be on only one row:

SaleID Amount SalesPerson Region

1 100 Tim, Sam USA

Can I make an expression do this somehow? Thanks!

1 Solution

Accepted Solutions
Highlighted
Partner
Partner

Turn several rows into one

When your table is already loaded (I will call it OriginalTable)

you can make:

load SaleIdD, Amount, concat(SalesPerson',', ') as SalesPeople,

//if you don't change at least one field name you will have to use noconcatenate before LOAD statement

Region

resident OriginalTable

group by SaleID, Amount, Region;

drop table OriginalTable;// if you don't drop it's better to change field names

View solution in original post

3 Replies
Highlighted
Partner
Partner

Turn several rows into one

When your table is already loaded (I will call it OriginalTable)

you can make:

load SaleIdD, Amount, concat(SalesPerson',', ') as SalesPeople,

//if you don't change at least one field name you will have to use noconcatenate before LOAD statement

Region

resident OriginalTable

group by SaleID, Amount, Region;

drop table OriginalTable;// if you don't drop it's better to change field names

View solution in original post

Highlighted
Specialist
Specialist

Turn several rows into one

Hi

maybe you can use concat() and group by clauses like this

Load

SaleID,
Amount,
Region,
Concat(SalesPerson,',') as SalesPersonConcat
from/resident
group by
SaleID,
Amount,
Region

Rgds

PS. depending on your data, maybe you can use max(Amount) or Avg(Amount) or Sum(Amount), instead of grouping by the field

Highlighted
Not applicable

Turn several rows into one

I ended up just using the concat(SalesPerson',', ') in a expression and it works! hoooray!!