Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
beck_bakytbek
Master
Master

Concat and Count

Hi Folks,

i got a situation:

temp:

OrderID, Product, Turnover

101, Road Bikes, 25

101, Chains, 25

102, Road Bikes, 5

102, Footwear, 15

103, Chains, 7

left join

load OrderID, Concat(Product, ' , ' ) as Product

resident temp

group by OrderID;

my resultstable does look like:

OrderID, Products, Turnover

101, Road Bikes, Chains, 50

102, Road Bikes, Footwear, 20

103, Chains, 7

I want to have such tables

OrderID, Products, Turnover

101, 2, 50

102, 2, 20

103, 1, 7

How to implement the ProductsName into Number?

Does anybody have any idea?

Thanks a lot

Beck

1 Solution

Accepted Solutions
OmarBenSalem

Hi Beck

It worked for me:

load *, SubStringCount(Products,'- ')+1 as count Inline [

OrderID, Products, Turnover

101, Road Bikes- Chains, 50

102, Road Bikes- Footwear, 20

103, Chains, 7

];

result:

Capture.PNG

Mybe u should recall ur table and then do the transformation:

sthng like:

noconcatenate

load *,  SubStringCount(Products,', ')+1 as NewProdcuct resident urTable;

drop urTable;

View solution in original post

8 Replies
Quy_Nguyen
Specialist
Specialist

Try this:

A:

Load * INLINE [

OrderID, Product, Turnover

101, Road Bikes, 25

101, Chains, 25

102, Road Bikes, 5

102, Footwear, 15

103, Chains, 7 ];


NoConcatenate

Data:

Load

OrderID,

    Count(Product) As Product,

    Sum(Turnover) As Turnover

Resident A

Group by OrderID;


Drop Table A;

OmarBenSalem

Try :

temp:

OrderID, Product, Turnover

101, Road Bikes, 25

101, Chains, 25

102, Road Bikes, 5

102, Footwear, 15

103, Chains, 7

left join

load OrderID, SubStringCountConcat((Product, ' , ' ), ' , ')+1 as Product

resident temp

group by OrderID;

beck_bakytbek
Master
Master
Author

Hi Omar,

how are you, thanks a lot for your responce, i implemented it, but it does not work

OmarBenSalem

Hi Beck

It worked for me:

load *, SubStringCount(Products,'- ')+1 as count Inline [

OrderID, Products, Turnover

101, Road Bikes- Chains, 50

102, Road Bikes- Footwear, 20

103, Chains, 7

];

result:

Capture.PNG

Mybe u should recall ur table and then do the transformation:

sthng like:

noconcatenate

load *,  SubStringCount(Products,', ')+1 as NewProdcuct resident urTable;

drop urTable;

beck_bakytbek
Master
Master
Author

Thanks a lot Omar for your time and help,

as always i say; shukraan 'akhi

Have a nice evening

Beck

beck_bakytbek
Master
Master
Author

Hi Quy,

thanks a lot for your help and time

nsetty
Partner - Creator II
Partner - Creator II

AutoNumber(Product) ?

Quy_Nguyen
Specialist
Specialist

I dont know what's wrong with my answer Beck