Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Dynamic row to column conversion

  1. #1

    Default Dynamic row to column conversion

    Hi,

    I need to convert data from rows to columns dynamically. Let me explain it with example.

    Say, source data is:-
    Code:
    select 'ABC-123' as company_id, 4343 amt from dual union all 
    select 'PQR-111' as company_id, 1111 amt from dual union all 
    select 'XYZ-222' as company_id, 2345 amt from dual union all 
    select 'DDD-333' as company_id, 9999 amt from dual union all 
    select 'IJK-444' as company_id, 1122 amt from dual union all 
    select 'KLM-555' as company_id, 3344 amt from dual union all 
    select 'BRT-666' as company_id, 5555 amt from dual union all 
    select 'IND-777' as company_id, 6666 amt from dual
    I need excel output where company_id will become header and amt will become corresponding value under the header. Here is the expected output (excel):-
    ABC-123 PQR-111 XYZ-222 DDD-333 IJK-444 KLM-555 BRT-666 IND-777
    4343 1111 2345 9999 1122 3344 5555 6666

    Number of rows in source data is not fixed. In sample data, it is having 8 rows and hence, excel output is having 8 columns. However it should be dynamic. If source data is having 20 rows, then I should be having 20 columns in excel output.

    Request you all to take a look. Any help will be much appreciated.

    Regards,
    Ritesh

  2. #2
    Join Date
    Apr 2008
    Posts
    4,690

    Default

    Use Metadata Injection and Row Denormalizer.

    Row Denormalizer needs to know how many columns to make. The Metadata Injection can figure that out and send it to the template transformation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.