Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Working with Tables in the Script

Hello all,

I'm a new user to QlikView. 

I have a table in a source Excel file (which I can't change) with fields as follows: Company, 1990, 1991, 1992, 1993, etc. where "Company" is the name of the applicable company and the year fields contain sales information.  There are about 30 years in total.

For workability, I would like to change the structure of the table during the load to have only 3 fields: Company, Year, Sales and "stack" the year fields.

Has anyone else tried this? Could you recommend an efficient solution?

Thank you!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try a CROSSTABLE LOAD prefix, something like

CROSSTABLE (Year, Sales,1) LOAD * FROM YourTable;

Check the Help for more details on CROSSTABLE.

Regards,

Stefan

edit:

To make this work, your input fields need to be in order: Company, 1990, 1991, 1992, ...

i.e. Company should be first in order when loading from your source. You may need to specify your field order explicitely, if needed.

View solution in original post

3 Replies
swuehl
MVP
MVP

Try a CROSSTABLE LOAD prefix, something like

CROSSTABLE (Year, Sales,1) LOAD * FROM YourTable;

Check the Help for more details on CROSSTABLE.

Regards,

Stefan

edit:

To make this work, your input fields need to be in order: Company, 1990, 1991, 1992, ...

i.e. Company should be first in order when loading from your source. You may need to specify your field order explicitely, if needed.

MayilVahanan

Hi

Try a CROSSTABLE concept,

Ex:

CROSSTABLE (Year, Sales,1)

LOAD * FROM YourTableName;

Hope it helps


Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Thank you! This worked.

A follow up question: I simplified my example a bit - I had actually added a new field to my table in the LOAD statement.

LOAD

     .....,

     'Auto' as BusinessLine

FROM ..... 

Now that I have the

CROSSTABLE (.......) Load, the new field doesn't get added properly.

I've addressed this by loading a new table including all fields of the crosstable, adding this new field and dropping the old table. This works, but it makes my code quite long.  Is this the only alternative?