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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to convert comma separated values to row values

I have data in this format

    

Project IDFirmYearKPIInventors
6417100AMD2002205736423-1;04294002-2;04954459-1
6415975AMD2002106193134-1;06028350-1
6400160AMD2002806400160-1

I want in this format

    

Project IDFirmYearKPIInventors
6417100AMD2002205736423-1
6417100AMD2002204294002-2
6417100AMD2002204954459-1
6415975AMD2002106193134-1
6415975AMD2002106028350-1
6400160AMD20028

06400160-1

Also I want count of inventors like this

     

Project IDFirmYearKPIInventorsCount of Inventors
6417100AMD2002205736423-1;04294002-2;04954459-13
6415975AMD2002106193134-1;06028350-12
6400160AMD2002806400160-11

Please provide the code as I am using personal edition. Thanks in advance

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Table:

LOAD [Project ID],

          Firm,

          Year,

          KPI,

          SubField(Inventors, ';') as Inventors,

          (SubStringCount(Inventors, ';') + 1) as [Count of Inventors]

FROM Source;

View solution in original post

5 Replies
sunny_talwar

Try this:

Table:

LOAD [Project ID],

          Firm,

          Year,

          KPI,

          SubField(Inventors, ';') as Inventors,

          (SubStringCount(Inventors, ';') + 1) as [Count of Inventors]

FROM Source;

Not applicable
Author

Can I get distinct count instead of count?

sunny_talwar

Try this:

Table:

LOAD RowNo() as RowNo,

  [Project ID],

     Firm,

     Year,

     KPI,

     SubField(Inventors, ';') as Inventors;

LOAD * Inline [

Project ID, Firm, Year, KPI, Inventors

6417100, AMD, 2002, 2, 05736423-1;04294002-2;04954459-1;04954459-1

6415975, AMD, 2002, 1, 06193134-1;06028350-1

6400160, AMD, 2002, 8, 06400160-1;06400160-1

];

Left Join (Table)

LOAD [Project ID],

  Count(DISTINCT Inventors) as [Count of Inventors]

Resident Table

Group By [Project ID];

Not applicable
Author

So you mean there is no direct way of doing that like substringcount

sunny_talwar

I don't think SubStringCount will work for Distinct Count